@myrialabs/clopen 0.4.37 → 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 (193) hide show
  1. package/README.md +2 -2
  2. package/backend/auth/permissions.ts +39 -0
  3. package/backend/bootstrap.ts +16 -0
  4. package/backend/chat/stream-manager.ts +1 -1
  5. package/backend/database/crypto/envelope.test.ts +93 -0
  6. package/backend/database/crypto/envelope.ts +127 -0
  7. package/backend/database/crypto/index.ts +22 -0
  8. package/backend/database/crypto/master-key.ts +129 -0
  9. package/backend/database/crypto/secret-columns.ts +151 -0
  10. package/backend/database/migrations/071_create_notes_tables.ts +90 -0
  11. package/backend/database/migrations/072_encrypt_stored_secrets.ts +107 -0
  12. package/backend/database/migrations/073_create_integration_tables.ts +119 -0
  13. package/backend/database/migrations/074_create_work_tables.ts +94 -0
  14. package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
  15. package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
  16. package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
  17. package/backend/database/migrations/index.ts +49 -0
  18. package/backend/database/queries/db-client-connection-queries.ts +42 -12
  19. package/backend/database/queries/deploy-queries.ts +124 -0
  20. package/backend/database/queries/engine-queries.ts +23 -10
  21. package/backend/database/queries/graph-queries.ts +291 -247
  22. package/backend/database/queries/index.ts +10 -1
  23. package/backend/database/queries/integration-db-link-queries.ts +168 -0
  24. package/backend/database/queries/integration-queries.ts +325 -0
  25. package/backend/database/queries/mcp-server-queries.ts +38 -11
  26. package/backend/database/queries/note-queries.test.ts +190 -0
  27. package/backend/database/queries/note-queries.ts +269 -0
  28. package/backend/database/queries/profile-queries.ts +1 -1
  29. package/backend/database/queries/ssh-connection-queries.ts +19 -8
  30. package/backend/database/queries/work-queries.ts +210 -0
  31. package/backend/db-client/integrations/index.ts +37 -0
  32. package/backend/db-client/integrations/links.ts +533 -0
  33. package/backend/db-client/integrations/projector.test.ts +280 -0
  34. package/backend/db-client/integrations/projector.ts +256 -0
  35. package/backend/db-client/integrations/supabase-service.ts +266 -0
  36. package/backend/db-client/providers/registry.ts +27 -0
  37. package/backend/db-client/providers/supabase/adapter.ts +500 -0
  38. package/backend/db-client/providers/supabase/api-types.ts +92 -0
  39. package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
  40. package/backend/db-client/providers/supabase/client.ts +259 -0
  41. package/backend/db-client/providers/supabase/features.ts +502 -0
  42. package/backend/db-client/providers/supabase/local.test.ts +78 -0
  43. package/backend/db-client/providers/supabase/local.ts +137 -0
  44. package/backend/db-client/providers/types.ts +137 -0
  45. package/backend/deployments/bindings.test.ts +43 -0
  46. package/backend/deployments/bindings.ts +216 -0
  47. package/backend/deployments/index.ts +53 -0
  48. package/backend/deployments/log-streams.ts +214 -0
  49. package/backend/deployments/prompts.ts +70 -0
  50. package/backend/deployments/providers/vercel/adapter.ts +757 -0
  51. package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
  52. package/backend/deployments/providers/vercel/build-logs.ts +211 -0
  53. package/backend/deployments/providers/vercel/client.ts +203 -0
  54. package/backend/deployments/providers/vercel/list.test.ts +624 -0
  55. package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
  56. package/backend/deployments/providers/vercel/normalise.ts +113 -0
  57. package/backend/deployments/providers/vercel/types.ts +104 -0
  58. package/backend/deployments/registry.ts +27 -0
  59. package/backend/deployments/service.ts +458 -0
  60. package/backend/deployments/types.ts +278 -0
  61. package/backend/engine/docs/artifacts.md +22 -9
  62. package/backend/files/os-clipboard.test.ts +209 -0
  63. package/backend/files/os-clipboard.ts +567 -0
  64. package/backend/http/integration-hooks.ts +42 -0
  65. package/backend/http/notes-images.test.ts +228 -0
  66. package/backend/http/notes-images.ts +196 -0
  67. package/backend/index.ts +13 -0
  68. package/backend/integrations/accounts.ts +229 -0
  69. package/backend/integrations/health.ts +146 -0
  70. package/backend/integrations/index.ts +36 -0
  71. package/backend/integrations/projections/index.ts +0 -0
  72. package/backend/integrations/projections/mcp-projector.test.ts +204 -0
  73. package/backend/integrations/projections/mcp-projector.ts +163 -0
  74. package/backend/integrations/projections/types.ts +63 -0
  75. package/backend/integrations/registry/define.ts +38 -0
  76. package/backend/integrations/registry/index.ts +60 -0
  77. package/backend/integrations/registry/providers/context7.ts +44 -0
  78. package/backend/integrations/registry/providers/firecrawl.ts +41 -0
  79. package/backend/integrations/registry/providers/github.ts +78 -0
  80. package/backend/integrations/registry/providers/supabase.ts +61 -0
  81. package/backend/integrations/registry/providers/vercel.ts +46 -0
  82. package/backend/integrations/registry/types.ts +96 -0
  83. package/backend/integrations/webhooks/gateway.ts +160 -0
  84. package/backend/integrations/webhooks/verify.ts +65 -0
  85. package/backend/mcp/README.md +25 -3
  86. package/backend/mcp/external/config.ts +35 -1
  87. package/backend/mcp/index.ts +1 -1
  88. package/backend/mcp/internal/config.ts +1 -1
  89. package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
  90. package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
  91. package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
  92. package/backend/memory/README.md +57 -34
  93. package/backend/memory/compose.test.ts +3 -3
  94. package/backend/memory/compose.ts +6 -9
  95. package/backend/memory/config.ts +0 -5
  96. package/backend/memory/consolidate.ts +1 -2
  97. package/backend/memory/context.test.ts +8 -54
  98. package/backend/memory/context.ts +19 -25
  99. package/backend/memory/extract/episodic.ts +10 -12
  100. package/backend/memory/extract/index.ts +23 -52
  101. package/backend/memory/extract/scheduler.ts +3 -6
  102. package/backend/memory/index.ts +6 -5
  103. package/backend/memory/invalidate.ts +36 -48
  104. package/backend/memory/layout.ts +319 -130
  105. package/backend/memory/retention.ts +12 -42
  106. package/backend/memory/retrieval.eval.test.ts +2 -2
  107. package/backend/memory/retrieval.test.ts +228 -183
  108. package/backend/memory/retrieval.ts +22 -21
  109. package/backend/memory/revise.test.ts +62 -116
  110. package/backend/memory/revise.ts +0 -1
  111. package/backend/memory/view.ts +8 -5
  112. package/backend/notes/access.test.ts +82 -0
  113. package/backend/notes/access.ts +27 -0
  114. package/backend/notes/storage.test.ts +77 -0
  115. package/backend/notes/storage.ts +114 -0
  116. package/backend/permissions/service.ts +2 -2
  117. package/backend/profiles/service.ts +1 -1
  118. package/backend/projects/project-cleanup.ts +6 -0
  119. package/backend/snapshot/helpers.ts +35 -41
  120. package/backend/snapshot/snapshot-service.ts +90 -0
  121. package/backend/snapshot/turn-changes.test.ts +163 -0
  122. package/backend/snapshot/turn-changes.ts +131 -0
  123. package/backend/work/bindings.ts +124 -0
  124. package/backend/work/index.ts +42 -0
  125. package/backend/work/prompts.ts +150 -0
  126. package/backend/work/providers/github/actions-logs.ts +180 -0
  127. package/backend/work/providers/github/adapter.test.ts +88 -0
  128. package/backend/work/providers/github/adapter.ts +1255 -0
  129. package/backend/work/providers/github/client.ts +280 -0
  130. package/backend/work/providers/github/list-range.test.ts +158 -0
  131. package/backend/work/providers/github/token-kind.test.ts +42 -0
  132. package/backend/work/pull-requests.ts +242 -0
  133. package/backend/work/registry.ts +27 -0
  134. package/backend/work/service.ts +436 -0
  135. package/backend/work/start-work.test.ts +71 -0
  136. package/backend/work/start-work.ts +232 -0
  137. package/backend/work/types.ts +180 -0
  138. package/backend/ws/db-client/accounts.ts +225 -0
  139. package/backend/ws/db-client/connections.ts +34 -3
  140. package/backend/ws/db-client/context.ts +37 -0
  141. package/backend/ws/db-client/index.ts +20 -1
  142. package/backend/ws/db-client/supabase.ts +188 -0
  143. package/backend/ws/deployments/actions.ts +360 -0
  144. package/backend/ws/deployments/context.ts +43 -0
  145. package/backend/ws/deployments/crud.ts +152 -0
  146. package/backend/ws/deployments/index.ts +15 -0
  147. package/backend/ws/deployments/schemas.ts +183 -0
  148. package/backend/ws/files/clipboard.ts +78 -0
  149. package/backend/ws/files/index.ts +5 -0
  150. package/backend/ws/git/diff-budget.ts +70 -11
  151. package/backend/ws/index.ts +16 -2
  152. package/backend/ws/integrations/crud.ts +219 -0
  153. package/backend/ws/integrations/index.ts +22 -0
  154. package/backend/ws/mcp/crud.ts +25 -1
  155. package/backend/ws/memory/crud.ts +4 -16
  156. package/backend/ws/notes/index.ts +278 -0
  157. package/backend/ws/profiles/crud.ts +1 -1
  158. package/backend/ws/snapshot/changes.ts +279 -0
  159. package/backend/ws/snapshot/index.ts +4 -3
  160. package/backend/ws/work/actions.ts +206 -0
  161. package/backend/ws/work/context.ts +51 -0
  162. package/backend/ws/work/crud.ts +347 -0
  163. package/backend/ws/work/index.ts +17 -0
  164. package/backend/ws/work/pull-requests.ts +177 -0
  165. package/backend/ws/work/schemas.ts +226 -0
  166. package/dist/assets/{index-sJmS_CCm.js → index-BrF6nqld.js} +1 -1
  167. package/dist/assets/{index-Bik9TCBi.js → index-C8Gi-b6U.js} +1 -1
  168. package/dist/assets/main-Bd3gb79F.css +1 -0
  169. package/dist/assets/main-Bo1hD7mt.js +1191 -0
  170. package/dist/index.html +2 -2
  171. package/package.json +1 -1
  172. package/shared/constants/engine-tools.ts +1 -1
  173. package/shared/constants/tool-icons.ts +42 -0
  174. package/shared/types/database/schema.ts +41 -0
  175. package/shared/types/db-client/connection.ts +6 -0
  176. package/shared/types/db-client/index.ts +2 -0
  177. package/shared/types/db-client/integrations.ts +174 -0
  178. package/shared/types/db-client/supabase.ts +131 -0
  179. package/shared/types/deployments.ts +382 -0
  180. package/shared/types/integrations.ts +140 -0
  181. package/shared/types/memory.ts +34 -51
  182. package/shared/types/stores/settings.ts +8 -0
  183. package/shared/types/ui/components.ts +1 -1
  184. package/shared/types/work.ts +426 -0
  185. package/shared/utils/diff-calculator.test.ts +89 -0
  186. package/shared/utils/diff-calculator.ts +30 -65
  187. package/shared/utils/logger.ts +4 -0
  188. package/backend/memory/extract/languages.ts +0 -176
  189. package/backend/memory/extract/structural.test.ts +0 -215
  190. package/backend/memory/extract/structural.ts +0 -364
  191. package/backend/ws/snapshot/content.ts +0 -85
  192. package/dist/assets/main-DLqolBI2.css +0 -1
  193. package/dist/assets/main-Df1I3hnw.js +0 -1096
@@ -0,0 +1,382 @@
1
+ /**
2
+ * Deployments surface — shared vocabulary.
3
+ *
4
+ * The panel talks about DEPLOYMENTS, not about Vercel. Every provider that can
5
+ * offer the `deployments` capability is normalised into these shapes by an
6
+ * adapter, and the panel never learns which one answered. That is the whole
7
+ * test for this surface: if Netlify or Railway needs a second panel, these
8
+ * types are wrong and fixing them is the work — not adding a panel.
9
+ *
10
+ * Nothing here carries a credential. The adapter resolves the account's secret
11
+ * on the server and it never crosses this line.
12
+ */
13
+
14
+ /**
15
+ * The one state fact the UI is allowed to reason about.
16
+ *
17
+ * Providers name their states whatever they like — Vercel says `INITIALIZING`,
18
+ * `BUILDING`, `READY`; Netlify says `enqueued`, `building`, `ready`. The native
19
+ * name is shown verbatim in the detail pane, but colour, grouping and whether
20
+ * polling continues are decided from this normalised set alone. Anything in the
21
+ * frontend that reads a provider's own state string is a bug in the interface.
22
+ */
23
+ export type DeploymentState = 'queued' | 'building' | 'ready' | 'error' | 'canceled';
24
+
25
+ /**
26
+ * Which environment a deployment belongs to.
27
+ *
28
+ * `custom` exists because Vercel has custom environments and Netlify has branch
29
+ * deploys, and collapsing either into `preview` would make the filter lie.
30
+ */
31
+ export type DeploymentEnvironment = 'production' | 'preview' | 'custom';
32
+
33
+ /** What the list can be narrowed to. `all` is the absence of a filter. */
34
+ export type DeploymentEnvironmentFilter = DeploymentEnvironment | 'all';
35
+
36
+ export interface Deployment {
37
+ /** Opaque provider id. Used for API calls, never shown. */
38
+ id: string;
39
+ /** The project/app name the provider reports, for multi-project accounts. */
40
+ name: string;
41
+ /**
42
+ * Where this build can be reached, without a scheme.
43
+ *
44
+ * Null while a deployment is still uploading — Vercel documents `url` as
45
+ * null for an incomplete deployment, and rendering `https://null` is worse
46
+ * than rendering nothing.
47
+ */
48
+ url: string | null;
49
+ /** The provider's own dashboard page for this build. */
50
+ inspectorUrl: string | null;
51
+ state: DeploymentState;
52
+ /** The provider's own state name, shown as-is in the detail pane. */
53
+ stateDetail: string;
54
+ environment: DeploymentEnvironment;
55
+ /**
56
+ * True when this deployment is the one currently serving production traffic.
57
+ *
58
+ * Distinct from `state === 'ready' && environment === 'production'`: a
59
+ * production build that was superseded, or rolled back away from, is ready
60
+ * and production and yet serves nobody.
61
+ */
62
+ isCurrent: boolean;
63
+ /**
64
+ * The provider says this build can be rolled back to.
65
+ *
66
+ * NULLABLE on purpose. `false` and "the provider did not say" are different
67
+ * answers, and collapsing them into `false` HID the rollback action on every
68
+ * deployment whose listing omitted the field — the action existed and was
69
+ * simply unreachable. Null means fall back to what is knowable: a ready
70
+ * production build that is not the live one.
71
+ */
72
+ isRollbackCandidate: boolean | null;
73
+ branch: string | null;
74
+ commitSha: string | null;
75
+ commitMessage: string | null;
76
+ creator: string | null;
77
+ createdAt: string;
78
+ buildingAt: string | null;
79
+ readyAt: string | null;
80
+ /** Machine-readable failure cause, when the provider gives one. */
81
+ errorCode: string | null;
82
+ errorMessage: string | null;
83
+ /** How the build was triggered — `git`, `cli`, `redeploy`. */
84
+ source: string | null;
85
+ }
86
+
87
+ export interface DeploymentDetail extends Deployment {
88
+ /** Every hostname pointing at this build, production aliases included. */
89
+ aliases: string[];
90
+ /** Framework the provider detected, when it reports one. */
91
+ framework: string | null;
92
+ /** Build duration in milliseconds, when both ends are known. */
93
+ durationMs: number | null;
94
+ }
95
+
96
+ export interface DeploymentPage {
97
+ items: Deployment[];
98
+ hasMore: boolean;
99
+ /**
100
+ * Opaque cursor for the next page.
101
+ *
102
+ * A cursor rather than a page number because Vercel paginates by timestamp
103
+ * and a page number would silently skip or repeat rows whenever a build
104
+ * lands mid-scroll. Providers that page by number encode it in here.
105
+ */
106
+ nextCursor: string | null;
107
+ rateLimit: DeployRateLimit | null;
108
+ }
109
+
110
+ /** Budget left on the provider's API, shown in the footer. */
111
+ export interface DeployRateLimit {
112
+ remaining: number;
113
+ limit: number;
114
+ resetAt: string | null;
115
+ }
116
+
117
+ /**
118
+ * What a provider can actually do.
119
+ *
120
+ * Every optional action is a flag rather than a try-and-see, because the
121
+ * alternative is a button that exists on every provider and 404s on most of
122
+ * them. Coolify has no promote, Fly has no preview deployment, and both must
123
+ * render a panel with those controls absent rather than disabled.
124
+ */
125
+ export interface DeployProviderCapabilities {
126
+ /** Build logs can be read at all. */
127
+ logs: boolean;
128
+ /**
129
+ * A build can be STARTED from here, not merely repeated.
130
+ *
131
+ * Separate from `redeploy`, which needs an existing deployment to copy. A
132
+ * project that has never been deployed has nothing to redeploy, and without
133
+ * this the panel is a dead end for exactly the project someone most wants to
134
+ * get onto a host.
135
+ */
136
+ createDeployment: boolean;
137
+ /** A new remote project can be created from here. */
138
+ createProject: boolean;
139
+ /** A git repository can be attached to an existing remote project. */
140
+ connectRepository: boolean;
141
+ /** A deployment can be deleted outright. */
142
+ deleteDeployment: boolean;
143
+ /** Logs arrive as a live stream rather than one fetched bundle. */
144
+ streamLogs: boolean;
145
+ redeploy: boolean;
146
+ cancel: boolean;
147
+ rollback: boolean;
148
+ promote: boolean;
149
+ /** The provider distinguishes production from preview builds. */
150
+ environments: boolean;
151
+ /** The list can be narrowed to one git branch. */
152
+ branchFilter: boolean;
153
+ }
154
+
155
+ /** A remote project this account could be pointed at, for the binding picker. */
156
+ export interface DeployTarget {
157
+ /** Opaque provider id — `prj_…` on Vercel. Stored as the binding's locator. */
158
+ id: string;
159
+ name: string;
160
+ /** Team or organisation scope, when the provider has one. */
161
+ teamId: string | null;
162
+ teamName: string | null;
163
+ framework: string | null;
164
+ /** `owner/repo` of the connected git repository, used to detect a binding. */
165
+ gitRepo: string | null;
166
+ }
167
+
168
+ /**
169
+ * What starting a build needs to know, resolved when the deploy dialog opens.
170
+ *
171
+ * Fetched on demand rather than carried on every source: it costs a request,
172
+ * and the overwhelming majority of panel opens never start a build.
173
+ */
174
+ export interface DeployInfo {
175
+ /** `owner/repo` the remote project builds from, or null when it has none. */
176
+ gitRepo: string | null;
177
+ /** The branch that produces a production build. */
178
+ productionBranch: string | null;
179
+ /**
180
+ * Whether a build can be started at all, and why not when it cannot.
181
+ *
182
+ * A remote project with no git connection can only be deployed by uploading
183
+ * files, which is a CLI job — saying so is better than a button that fails.
184
+ */
185
+ canDeploy: boolean;
186
+ reason: string | null;
187
+ /**
188
+ * `owner/repo` read off the LOCAL project's git remote.
189
+ *
190
+ * Carried so the dialog can offer to connect it when the remote project has
191
+ * no repository — the answer is already sitting in the working tree, and
192
+ * making someone type it is the setup step that sends them to the dashboard.
193
+ */
194
+ suggestedRepo: string | null;
195
+ /**
196
+ * Whether attaching `suggestedRepo` would actually work.
197
+ *
198
+ * Three states, not a boolean, because a boolean forces the uncertain case
199
+ * to pretend. The first version answered `true` when the check itself could
200
+ * not be read — which put the button back on screen and let the failure
201
+ * arrive as a toast, defeating the point of checking at all.
202
+ *
203
+ * ready — verified; the button can be pressed
204
+ * blocked — verified as impossible; the button must NOT be offered
205
+ * unknown — the check could not be read; we cannot prove either way
206
+ * unavailable — nothing to connect, or the provider cannot connect
207
+ */
208
+ connectState: 'ready' | 'blocked' | 'unknown' | 'unavailable';
209
+ /** What to do about it, when it is not ready. */
210
+ connectHint: string | null;
211
+ /** Where to go to fix it — the provider's own settings page. */
212
+ connectUrl: string | null;
213
+ /**
214
+ * The branch checked out in the local project right now.
215
+ *
216
+ * Offered alongside the production branch, because the branch someone is
217
+ * working on is at least as likely to be the one they want to deploy — and
218
+ * retyping it from memory is how a preview gets built from the wrong ref.
219
+ */
220
+ currentBranch: string | null;
221
+ }
222
+
223
+ /** What a new build is made from. */
224
+ export interface DeploymentDraft {
225
+ /** Branch or tag to build. */
226
+ ref: string;
227
+ /** Production rather than preview. Always the more dangerous choice. */
228
+ production: boolean;
229
+ }
230
+
231
+ /** Defaults offered when creating a remote project, read from the local one. */
232
+ export interface NewProjectDefaults {
233
+ suggestedName: string;
234
+ /** `owner/repo` from this project's git remote, when it has one. */
235
+ gitRepo: string | null;
236
+ /** Provider the remote belongs to, as the target host names it. */
237
+ gitProvider: string | null;
238
+ }
239
+
240
+ export interface NewProjectDraft {
241
+ name: string;
242
+ gitRepo: string | null;
243
+ gitProvider: string | null;
244
+ framework: string | null;
245
+ }
246
+
247
+ /** Per-binding behaviour. Not a secret, stored as plain JSON. */
248
+ export interface DeployBindingConfig {
249
+ /** Which environment the list opens on. */
250
+ environment: DeploymentEnvironmentFilter;
251
+ /**
252
+ * Keep polling the list while a build is running.
253
+ *
254
+ * On by default and switchable off, because this is a metered remote API and
255
+ * a user on a rate-limited plan watching a long build may prefer to refresh
256
+ * by hand.
257
+ */
258
+ autoRefresh: boolean;
259
+ }
260
+
261
+ export const DEFAULT_DEPLOY_BINDING_CONFIG: DeployBindingConfig = {
262
+ environment: 'all',
263
+ autoRefresh: true
264
+ };
265
+
266
+ /** The remote project one account is pointed at, as the panel sees it. */
267
+ export interface DeployBinding {
268
+ locator: string;
269
+ /**
270
+ * Human name of the remote project.
271
+ *
272
+ * Cached on the binding rather than derived from the locator, because unlike
273
+ * an `owner/repo` a Vercel locator is `prj_8Qc…` and means nothing to anyone.
274
+ * A binding bar rendering the raw id would be unreadable.
275
+ */
276
+ displayName: string;
277
+ detected: boolean;
278
+ teamId: string | null;
279
+ config: DeployBindingConfig;
280
+ }
281
+
282
+ /** One connected account able to serve deployments here. */
283
+ export interface DeploySource {
284
+ accountId: string;
285
+ provider: string;
286
+ providerName: string;
287
+ label: string;
288
+ /**
289
+ * Who the stored credential belongs to.
290
+ *
291
+ * Resolved once per source rather than per view. Shown in the footer beside
292
+ * the provider mark, the way the Issues surface shows it — a panel acting on
293
+ * someone's account should say whose.
294
+ */
295
+ viewer: string | null;
296
+ capabilities: DeployProviderCapabilities;
297
+ binding: DeployBinding | null;
298
+ /** Remote projects detected for this project, offered before the full list. */
299
+ suggestedTargets: DeployTarget[];
300
+ status: 'ok' | 'needs_auth' | 'needs_config' | 'error' | 'unknown';
301
+ statusDetail: string | null;
302
+ }
303
+
304
+ /** Build log text, already budgeted to something a prompt can carry. */
305
+ export interface BuildLogBundle {
306
+ deploymentId: string;
307
+ text: string;
308
+ truncated: boolean;
309
+ }
310
+
311
+ /**
312
+ * An action that triggers a build or changes what is live.
313
+ *
314
+ * Named as a closed set so the confirm dialog, the capability flags and the
315
+ * route schema all agree on what exists. Every one of these is outward-facing
316
+ * and must be confirmed explicitly before it runs.
317
+ */
318
+ export type DeployAction = 'redeploy' | 'cancel' | 'rollback' | 'promote' | 'delete';
319
+
320
+ /**
321
+ * The outcome of an outward-facing action.
322
+ *
323
+ * `pending` is not a courtesy — rollback and promote are asynchronous on
324
+ * Vercel: the call returns once the request is accepted, while production
325
+ * traffic moves some seconds later. Reporting those as done would tell the user
326
+ * their incident is over before it is.
327
+ */
328
+ export interface DeployActionResult {
329
+ action: DeployAction;
330
+ status: 'done' | 'pending';
331
+ /** A new deployment id, when the action created one. */
332
+ deploymentId: string | null;
333
+ message: string;
334
+ }
335
+
336
+ /**
337
+ * Project-level state, which belongs to the target rather than to any build.
338
+ *
339
+ * Read separately from the deployment list because it answers a different
340
+ * question: not "how did this build go" but "will pushing even produce one".
341
+ */
342
+ export interface DeployProjectStatus {
343
+ /**
344
+ * The target is paused at the provider.
345
+ *
346
+ * READ-ONLY here on purpose. Clopen does not offer to pause: on Vercel it
347
+ * "blocks the active Production Deployment" — it takes the site down, not
348
+ * merely stops future builds — and that is a high-consequence, rarely-wanted
349
+ * action to reach from an editor. But if someone paused it in the provider's
350
+ * dashboard, this is the only thing that explains a list which has stopped
351
+ * growing and a site that has stopped answering.
352
+ */
353
+ paused: boolean;
354
+ /**
355
+ * A rollback or promotion the provider accepted and is still carrying out.
356
+ *
357
+ * This is what turns the `pending` an action returns into an outcome. Until
358
+ * it settles, production traffic has not moved yet.
359
+ */
360
+ aliasRequest: {
361
+ type: 'rollback' | 'promote';
362
+ status: 'pending' | 'in-progress' | 'succeeded' | 'failed' | 'skipped';
363
+ toDeploymentId: string | null;
364
+ } | null;
365
+ }
366
+
367
+ /** One chunk of a live build log, pushed to whoever asked to follow it. */
368
+ export interface BuildLogChunk {
369
+ streamId: string;
370
+ deploymentId: string;
371
+ data: string;
372
+ /**
373
+ * Stage the provider reports — `Building`, `Uploading`, `Deploying`.
374
+ *
375
+ * Carried separately from the text because a build spends long stretches
376
+ * printing nothing at all, and during those a reader cannot tell work from
377
+ * a stall. Pushed the moment it changes rather than on the flush interval.
378
+ */
379
+ phase?: string;
380
+ done?: boolean;
381
+ error?: string | null;
382
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Third-party integrations — shared vocabulary.
3
+ *
4
+ * A connected account is NOT a feature. It is a credential with capabilities.
5
+ * Settings → Integrations is where you connect; what an integration DOES lives
6
+ * in the surface that owns that kind of work. These types are the contract
7
+ * between the two, and they are shared because the hub renders provider
8
+ * metadata the backend registry declares.
9
+ */
10
+
11
+ /**
12
+ * What an account can offer, and therefore which surface it projects onto.
13
+ *
14
+ * The full set is declared here from the start so a provider can honestly say
15
+ * what it supports, but only the surfaces that exist can be projected. Today
16
+ * that is `agent-tools`; each later surface registers its own projector.
17
+ */
18
+ export const INTEGRATION_CAPABILITIES = [
19
+ 'agent-tools',
20
+ /** Issues, pull requests and CI — the Issues & PRs surface. */
21
+ 'work',
22
+ 'deployments',
23
+ 'database',
24
+ 'worktree-branching',
25
+ 'notifications',
26
+ 'inbound-events'
27
+ ] as const;
28
+
29
+ export type IntegrationCapability = typeof INTEGRATION_CAPABILITIES[number];
30
+
31
+ /** How the credential is obtained. */
32
+ export type IntegrationAuthMethod =
33
+ | 'api-key'
34
+ | 'oauth-device'
35
+ | 'oauth-code'
36
+ | 'mcp-oauth'
37
+ | 'connection-string'
38
+ | 'none';
39
+
40
+ /**
41
+ * Declared as a const array rather than a bare union so the WebSocket schema can
42
+ * be generated from it. A `t.String()` there would widen `category` back to
43
+ * `string` on the client and quietly break every lookup keyed by it.
44
+ */
45
+ export const INTEGRATION_CATEGORIES = [
46
+ 'source-control',
47
+ 'issues',
48
+ 'deployment',
49
+ 'database',
50
+ 'observability',
51
+ 'chat',
52
+ 'research',
53
+ 'design',
54
+ 'developer-services',
55
+ 'secrets'
56
+ ] as const;
57
+
58
+ export type IntegrationCategory = typeof INTEGRATION_CATEGORIES[number];
59
+
60
+ /** One field of a provider's credential, as rendered by the connect dialog. */
61
+ export interface IntegrationCredentialField {
62
+ /** Key inside the account's credentials object. */
63
+ name: string;
64
+ label: string;
65
+ placeholder?: string;
66
+ help?: string;
67
+ isSecret: boolean;
68
+ isRequired: boolean;
69
+ }
70
+
71
+ /** Health of a connected account, mirroring the MCP probe vocabulary. */
72
+ export type IntegrationStatus = 'unknown' | 'ok' | 'needs_auth' | 'needs_config' | 'error';
73
+
74
+ /** A provider as the hub sees it. No icon field — the brand mark is keyed by id. */
75
+ export interface IntegrationProviderInfo {
76
+ id: string;
77
+ name: string;
78
+ category: IntegrationCategory;
79
+ description: string;
80
+ docsUrl?: string;
81
+ authMethod: IntegrationAuthMethod;
82
+ credentialFields: IntegrationCredentialField[];
83
+ capabilities: IntegrationCapability[];
84
+ defaultCapabilities: IntegrationCapability[];
85
+ /** True when connecting projects an MCP server row. */
86
+ providesAgentTools: boolean;
87
+ /** True when the provider can receive inbound webhooks. */
88
+ acceptsWebhooks: boolean;
89
+ }
90
+
91
+ /** A connected account as the hub sees it. Credential VALUES never cross this line. */
92
+ export interface IntegrationAccountInfo {
93
+ id: string;
94
+ provider: string;
95
+ label: string;
96
+ projectId: string | null;
97
+ authMethod: IntegrationAuthMethod;
98
+ /** Which credential fields currently hold a value — never the values themselves. */
99
+ configuredFields: string[];
100
+ capabilities: IntegrationCapability[];
101
+ status: IntegrationStatus;
102
+ statusDetail: string | null;
103
+ checkedAt: string | null;
104
+ isEnabled: boolean;
105
+ createdAt: string;
106
+ updatedAt: string;
107
+ /** Surfaces this account currently owns a row on. */
108
+ projections: IntegrationProjectionInfo[];
109
+ }
110
+
111
+ export interface IntegrationProjectionInfo {
112
+ capability: IntegrationCapability;
113
+ targetKind: IntegrationTargetKind;
114
+ targetId: string;
115
+ /** True when the row existed before the account did and will be handed back on disconnect. */
116
+ adopted: boolean;
117
+ }
118
+
119
+ /** Surfaces a capability can project onto. One entry per row in the architecture table. */
120
+ export type IntegrationTargetKind = 'mcp_server' | 'db_client_connection';
121
+
122
+ /**
123
+ * Secrets-at-rest health, surfaced as a banner in the hub.
124
+ *
125
+ * A non-zero count means the active key cannot open values that are in the
126
+ * database — almost always a restored backup meeting a freshly generated key.
127
+ */
128
+ export interface SecretsHealth {
129
+ /** Where the active master key came from. */
130
+ keySource: 'env' | 'file';
131
+ /** Fingerprint of the active key — matches the stamp inside every envelope. */
132
+ keyFingerprint: string;
133
+ /** Values the active key could not open since process start. */
134
+ failureCount: number;
135
+ lastFailureAt: string | null;
136
+ /** Fingerprints seen on values we could not open. */
137
+ unknownKeyFingerprints: string[];
138
+ /** Declared secret columns still holding plaintext. */
139
+ unsealedColumns: { table: string; column: string; count: number }[];
140
+ }