@myrialabs/clopen 0.4.38 → 0.4.40

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 (177) hide show
  1. package/backend/auth/permissions.ts +48 -0
  2. package/backend/chat/stream-manager.ts +1 -1
  3. package/backend/database/crypto/secret-columns.ts +9 -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/078_create_worktree_branch_tables.ts +158 -0
  8. package/backend/database/migrations/index.ts +28 -0
  9. package/backend/database/queries/db-client-connection-queries.ts +19 -0
  10. package/backend/database/queries/deploy-queries.ts +124 -0
  11. package/backend/database/queries/graph-queries.ts +291 -247
  12. package/backend/database/queries/index.ts +10 -0
  13. package/backend/database/queries/integration-db-link-queries.ts +168 -0
  14. package/backend/database/queries/integration-queries.ts +34 -6
  15. package/backend/database/queries/worktree-branch-queries.ts +331 -0
  16. package/backend/db-client/cloning.test.ts +161 -0
  17. package/backend/db-client/cloning.ts +672 -0
  18. package/backend/db-client/connection-url.test.ts +117 -0
  19. package/backend/db-client/connection-url.ts +126 -0
  20. package/backend/db-client/drivers/mongodb.ts +2 -14
  21. package/backend/db-client/drivers/mysql.ts +2 -8
  22. package/backend/db-client/drivers/postgres.ts +10 -13
  23. package/backend/db-client/drivers/redis.ts +2 -6
  24. package/backend/db-client/env/detect.ts +438 -0
  25. package/backend/db-client/env/diff.ts +94 -0
  26. package/backend/db-client/env/env.test.ts +574 -0
  27. package/backend/db-client/env/index.ts +15 -0
  28. package/backend/db-client/env/naming.ts +202 -0
  29. package/backend/db-client/env/service.ts +487 -0
  30. package/backend/db-client/integrations/index.ts +44 -0
  31. package/backend/db-client/integrations/links.ts +564 -0
  32. package/backend/db-client/integrations/projector.test.ts +280 -0
  33. package/backend/db-client/integrations/projector.ts +256 -0
  34. package/backend/db-client/integrations/supabase-service.ts +266 -0
  35. package/backend/db-client/providers/neon/adapter.ts +522 -0
  36. package/backend/db-client/providers/neon/api-types.ts +182 -0
  37. package/backend/db-client/providers/neon/client.ts +298 -0
  38. package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
  39. package/backend/db-client/providers/neon/endpoints.ts +314 -0
  40. package/backend/db-client/providers/neon/list.test.ts +181 -0
  41. package/backend/db-client/providers/registry.ts +27 -0
  42. package/backend/db-client/providers/supabase/adapter.ts +523 -0
  43. package/backend/db-client/providers/supabase/api-types.ts +92 -0
  44. package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
  45. package/backend/db-client/providers/supabase/client.ts +259 -0
  46. package/backend/db-client/providers/supabase/features.ts +502 -0
  47. package/backend/db-client/providers/supabase/local.test.ts +78 -0
  48. package/backend/db-client/providers/supabase/local.ts +137 -0
  49. package/backend/db-client/providers/types.ts +194 -0
  50. package/backend/deployments/bindings.test.ts +43 -0
  51. package/backend/deployments/bindings.ts +216 -0
  52. package/backend/deployments/index.ts +53 -0
  53. package/backend/deployments/log-streams.ts +214 -0
  54. package/backend/deployments/prompts.ts +70 -0
  55. package/backend/deployments/providers/vercel/adapter.ts +757 -0
  56. package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
  57. package/backend/deployments/providers/vercel/build-logs.ts +211 -0
  58. package/backend/deployments/providers/vercel/client.ts +203 -0
  59. package/backend/deployments/providers/vercel/list.test.ts +624 -0
  60. package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
  61. package/backend/deployments/providers/vercel/normalise.ts +113 -0
  62. package/backend/deployments/providers/vercel/types.ts +104 -0
  63. package/backend/deployments/registry.ts +27 -0
  64. package/backend/deployments/service.ts +458 -0
  65. package/backend/deployments/types.ts +278 -0
  66. package/backend/env-files/discovery.ts +48 -0
  67. package/backend/env-files/edit.ts +213 -0
  68. package/backend/env-files/env-files.test.ts +515 -0
  69. package/backend/env-files/git.ts +27 -0
  70. package/backend/env-files/index.ts +44 -0
  71. package/backend/env-files/keys.ts +69 -0
  72. package/backend/env-files/parse.ts +157 -0
  73. package/backend/env-files/write.ts +229 -0
  74. package/backend/index.ts +4 -0
  75. package/backend/integrations/health.ts +18 -4
  76. package/backend/integrations/projections/index.ts +0 -0
  77. package/backend/integrations/projections/mcp-projector.ts +7 -3
  78. package/backend/integrations/projections/types.ts +28 -9
  79. package/backend/integrations/registry/index.ts +8 -1
  80. package/backend/integrations/registry/providers/context7.ts +1 -0
  81. package/backend/integrations/registry/providers/firecrawl.ts +1 -0
  82. package/backend/integrations/registry/providers/github.ts +1 -0
  83. package/backend/integrations/registry/providers/neon.ts +55 -0
  84. package/backend/integrations/registry/providers/supabase.ts +62 -0
  85. package/backend/integrations/registry/providers/vercel.ts +47 -0
  86. package/backend/integrations/registry/types.ts +2 -0
  87. package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
  88. package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
  89. package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
  90. package/backend/memory/README.md +57 -34
  91. package/backend/memory/compose.test.ts +3 -3
  92. package/backend/memory/compose.ts +6 -9
  93. package/backend/memory/config.ts +0 -5
  94. package/backend/memory/consolidate.ts +1 -2
  95. package/backend/memory/context.test.ts +8 -54
  96. package/backend/memory/context.ts +19 -25
  97. package/backend/memory/extract/episodic.ts +10 -12
  98. package/backend/memory/extract/index.ts +23 -52
  99. package/backend/memory/extract/scheduler.ts +3 -6
  100. package/backend/memory/index.ts +6 -5
  101. package/backend/memory/invalidate.ts +36 -48
  102. package/backend/memory/layout.ts +319 -130
  103. package/backend/memory/retention.ts +12 -42
  104. package/backend/memory/retrieval.eval.test.ts +2 -2
  105. package/backend/memory/retrieval.test.ts +228 -183
  106. package/backend/memory/retrieval.ts +22 -21
  107. package/backend/memory/revise.test.ts +62 -116
  108. package/backend/memory/revise.ts +0 -1
  109. package/backend/memory/view.ts +8 -5
  110. package/backend/snapshot/helpers.ts +35 -41
  111. package/backend/snapshot/snapshot-service.ts +90 -0
  112. package/backend/snapshot/turn-changes.test.ts +163 -0
  113. package/backend/snapshot/turn-changes.ts +131 -0
  114. package/backend/work/start-work.ts +4 -0
  115. package/backend/worktrees/branching/engine.ts +557 -0
  116. package/backend/worktrees/branching/index.ts +56 -0
  117. package/backend/worktrees/branching/naming.test.ts +118 -0
  118. package/backend/worktrees/branching/naming.ts +97 -0
  119. package/backend/worktrees/branching/projector.test.ts +229 -0
  120. package/backend/worktrees/branching/projector.ts +139 -0
  121. package/backend/worktrees/branching/providers/neon.ts +220 -0
  122. package/backend/worktrees/branching/registry.ts +27 -0
  123. package/backend/worktrees/branching/service.ts +620 -0
  124. package/backend/worktrees/branching/suggest.test.ts +154 -0
  125. package/backend/worktrees/branching/suggest.ts +202 -0
  126. package/backend/worktrees/branching/types.ts +88 -0
  127. package/backend/worktrees/index.ts +7 -0
  128. package/backend/worktrees/service.ts +48 -1
  129. package/backend/ws/db-client/accounts.ts +225 -0
  130. package/backend/ws/db-client/connections.ts +34 -3
  131. package/backend/ws/db-client/context.ts +37 -0
  132. package/backend/ws/db-client/env.ts +142 -0
  133. package/backend/ws/db-client/index.ts +22 -1
  134. package/backend/ws/db-client/supabase.ts +188 -0
  135. package/backend/ws/deployments/actions.ts +360 -0
  136. package/backend/ws/deployments/context.ts +43 -0
  137. package/backend/ws/deployments/crud.ts +152 -0
  138. package/backend/ws/deployments/index.ts +15 -0
  139. package/backend/ws/deployments/schemas.ts +183 -0
  140. package/backend/ws/index.ts +6 -2
  141. package/backend/ws/memory/crud.ts +4 -16
  142. package/backend/ws/projects/index.ts +6 -1
  143. package/backend/ws/projects/info.ts +70 -6
  144. package/backend/ws/projects/overview.test.ts +108 -0
  145. package/backend/ws/projects/overview.ts +300 -0
  146. package/backend/ws/snapshot/changes.ts +279 -0
  147. package/backend/ws/snapshot/index.ts +4 -3
  148. package/backend/ws/system/device-info.ts +307 -76
  149. package/backend/ws/worktrees/branching.ts +212 -0
  150. package/backend/ws/worktrees/crud.ts +33 -7
  151. package/backend/ws/worktrees/index.ts +14 -0
  152. package/dist/assets/{index-DSHIANSy.js → index-D4igjF6e.js} +1 -1
  153. package/dist/assets/{index-CyH7fSbR.js → index-DONNwiXm.js} +1 -1
  154. package/dist/assets/main-BrfXH1bL.js +1205 -0
  155. package/dist/assets/main-CT1PygsW.css +1 -0
  156. package/dist/index.html +2 -2
  157. package/package.json +1 -1
  158. package/shared/constants/tool-icons.ts +13 -0
  159. package/shared/types/db-client/connection.ts +6 -0
  160. package/shared/types/db-client/env.ts +192 -0
  161. package/shared/types/db-client/index.ts +3 -0
  162. package/shared/types/db-client/integrations.ts +204 -0
  163. package/shared/types/db-client/supabase.ts +131 -0
  164. package/shared/types/deployments.ts +382 -0
  165. package/shared/types/integrations.ts +9 -0
  166. package/shared/types/memory.ts +34 -51
  167. package/shared/types/ui/components.ts +1 -1
  168. package/shared/types/worktree-branching.ts +315 -0
  169. package/shared/utils/diff-calculator.test.ts +89 -0
  170. package/shared/utils/diff-calculator.ts +30 -65
  171. package/shared/utils/logger.ts +2 -0
  172. package/backend/memory/extract/languages.ts +0 -176
  173. package/backend/memory/extract/structural.test.ts +0 -215
  174. package/backend/memory/extract/structural.ts +0 -364
  175. package/backend/ws/snapshot/content.ts +0 -85
  176. package/dist/assets/main-D2IOjftb.css +0 -1
  177. package/dist/assets/main-DM-tHKbW.js +0 -1152
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Reading deployments.
3
+ *
4
+ * deployments:sources which connected accounts serve a project
5
+ * deployments:list deployments for one source
6
+ * deployments:get one deployment, with aliases and timings
7
+ * deployments:targets remote projects this account can be pointed at
8
+ * deployments:set-binding point a project at a different remote project
9
+ * deployments:set-config per-binding behaviour (environment, auto-refresh)
10
+ * deployments:logs build logs as one budgeted bundle
11
+ *
12
+ * NOT admin-gated, unlike `integrations:*`. The distinction is what the route
13
+ * can reach: an integrations route changes a credential every project and every
14
+ * engine depends on, while these act inside one project the caller was already
15
+ * granted access to — the same reasoning that leaves `git:push` open.
16
+ *
17
+ * Every route takes an optional `projectId`, because this surface is global.
18
+ */
19
+
20
+ import { t } from 'elysia';
21
+ import { createRouter } from '$shared/utils/ws-server';
22
+ import { deployService } from '$backend/deployments';
23
+ import type { DeploymentEnvironmentFilter } from '$shared/types/deployments';
24
+ import { ws } from '$backend/utils/ws';
25
+ import { resolveDeployProject } from './context';
26
+ import {
27
+ DEPLOYMENT_DETAIL_SCHEMA,
28
+ DEPLOYMENT_SCHEMA,
29
+ DEPLOY_CONFIG_SCHEMA,
30
+ DEPLOY_SOURCE_SCHEMA,
31
+ DEPLOY_TARGET_SCHEMA,
32
+ ENVIRONMENT_FILTER_SCHEMA,
33
+ LOG_BUNDLE_SCHEMA,
34
+ RATE_LIMIT_SCHEMA
35
+ } from './schemas';
36
+
37
+ /**
38
+ * Tell a project's viewers that one of its sources changed.
39
+ *
40
+ * Project-scoped rather than global: a binding belongs to one project, and two
41
+ * people looking at different projects have no reason to refetch because of
42
+ * each other.
43
+ */
44
+ export function announceDeploymentsChanged(projectId: string): void {
45
+ ws.emit.project(projectId, 'deployments:changed', { projectId });
46
+ }
47
+
48
+ /** Present on every route in this surface. Empty means "the current project". */
49
+ const PROJECT_FIELD = { projectId: t.Optional(t.String()) };
50
+
51
+ export const deploymentsCrudHandler = createRouter()
52
+ .http('deployments:sources', {
53
+ data: t.Object({ ...PROJECT_FIELD }),
54
+ response: t.Array(DEPLOY_SOURCE_SCHEMA)
55
+ }, async ({ data, conn }) => {
56
+ const { projectId, root } = resolveDeployProject(conn, data.projectId);
57
+ return deployService.listSources(projectId, root);
58
+ })
59
+
60
+ .http('deployments:list', {
61
+ data: t.Object({
62
+ ...PROJECT_FIELD,
63
+ accountId: t.String({ minLength: 1 }),
64
+ environment: ENVIRONMENT_FILTER_SCHEMA,
65
+ branch: t.Optional(t.String()),
66
+ cursor: t.Optional(t.String())
67
+ }),
68
+ response: t.Object({
69
+ items: t.Array(DEPLOYMENT_SCHEMA),
70
+ hasMore: t.Boolean(),
71
+ nextCursor: t.Union([t.String(), t.Null()]),
72
+ rateLimit: t.Union([RATE_LIMIT_SCHEMA, t.Null()])
73
+ })
74
+ }, async ({ data, conn }) => {
75
+ const { projectId } = resolveDeployProject(conn, data.projectId);
76
+ return deployService.list(projectId, data.accountId, {
77
+ environment: data.environment as DeploymentEnvironmentFilter,
78
+ ...(data.branch && { branch: data.branch }),
79
+ ...(data.cursor && { cursor: data.cursor })
80
+ });
81
+ })
82
+
83
+ .http('deployments:get', {
84
+ data: t.Object({
85
+ ...PROJECT_FIELD,
86
+ accountId: t.String({ minLength: 1 }),
87
+ deploymentId: t.String({ minLength: 1 })
88
+ }),
89
+ response: DEPLOYMENT_DETAIL_SCHEMA
90
+ }, async ({ data, conn }) => {
91
+ const { projectId } = resolveDeployProject(conn, data.projectId);
92
+ return deployService.get(projectId, data.accountId, data.deploymentId);
93
+ })
94
+
95
+ .http('deployments:targets', {
96
+ data: t.Object({
97
+ ...PROJECT_FIELD,
98
+ accountId: t.String({ minLength: 1 })
99
+ }),
100
+ response: t.Array(DEPLOY_TARGET_SCHEMA)
101
+ }, async ({ data, conn }) => {
102
+ const { projectId, root } = resolveDeployProject(conn, data.projectId);
103
+ return deployService.listTargets(projectId, data.accountId, root);
104
+ })
105
+
106
+ .http('deployments:set-binding', {
107
+ data: t.Object({
108
+ ...PROJECT_FIELD,
109
+ accountId: t.String({ minLength: 1 }),
110
+ locator: t.String({ minLength: 1 }),
111
+ teamId: t.Optional(t.Union([t.String(), t.Null()]))
112
+ }),
113
+ response: t.Object({ ok: t.Boolean() })
114
+ }, async ({ data, conn }) => {
115
+ const { projectId } = resolveDeployProject(conn, data.projectId);
116
+ await deployService.setBinding(projectId, data.accountId, data.locator, data.teamId ?? null);
117
+ announceDeploymentsChanged(projectId);
118
+ return { ok: true };
119
+ })
120
+
121
+ .http('deployments:set-config', {
122
+ data: t.Object({
123
+ ...PROJECT_FIELD,
124
+ accountId: t.String({ minLength: 1 }),
125
+ config: DEPLOY_CONFIG_SCHEMA
126
+ }),
127
+ response: t.Object({ ok: t.Boolean() })
128
+ }, async ({ data, conn }) => {
129
+ const { projectId } = resolveDeployProject(conn, data.projectId);
130
+ deployService.setConfig(projectId, data.accountId, {
131
+ environment: data.config.environment as DeploymentEnvironmentFilter,
132
+ autoRefresh: data.config.autoRefresh
133
+ });
134
+ announceDeploymentsChanged(projectId);
135
+ return { ok: true };
136
+ })
137
+
138
+ .http('deployments:logs', {
139
+ data: t.Object({
140
+ ...PROJECT_FIELD,
141
+ accountId: t.String({ minLength: 1 }),
142
+ deploymentId: t.String({ minLength: 1 })
143
+ }),
144
+ response: LOG_BUNDLE_SCHEMA
145
+ }, async ({ data, conn }) => {
146
+ const { projectId } = resolveDeployProject(conn, data.projectId);
147
+ return deployService.fetchLogs(projectId, data.accountId, data.deploymentId);
148
+ })
149
+
150
+ .emit('deployments:changed', t.Object({
151
+ projectId: t.String()
152
+ }));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Deployments surface routes.
3
+ *
4
+ * Importing `$backend/deployments` is what registers the providers, so merging
5
+ * this router into the app is also what makes Vercel exist. That is deliberate:
6
+ * a surface with no routes has no adapters to register either.
7
+ */
8
+
9
+ import { createRouter } from '$shared/utils/ws-server';
10
+ import { deploymentsCrudHandler } from './crud';
11
+ import { deploymentsActionsHandler } from './actions';
12
+
13
+ export const deploymentsRouter = createRouter()
14
+ .merge(deploymentsCrudHandler)
15
+ .merge(deploymentsActionsHandler);
@@ -0,0 +1,183 @@
1
+ /**
2
+ * TypeBox shapes for the Deployments surface.
3
+ *
4
+ * Kept in one file because three handler modules serialise the same deployment,
5
+ * and a schema copied per handler is a schema that drifts per handler — the
6
+ * client's generated types then disagree with each other rather than with the
7
+ * server, which is much harder to notice.
8
+ */
9
+
10
+ import { t } from 'elysia';
11
+
12
+ export const DEPLOYMENT_STATE_SCHEMA = t.Union([
13
+ t.Literal('queued'),
14
+ t.Literal('building'),
15
+ t.Literal('ready'),
16
+ t.Literal('error'),
17
+ t.Literal('canceled')
18
+ ]);
19
+
20
+ export const ENVIRONMENT_SCHEMA = t.Union([
21
+ t.Literal('production'),
22
+ t.Literal('preview'),
23
+ t.Literal('custom')
24
+ ]);
25
+
26
+ export const ENVIRONMENT_FILTER_SCHEMA = t.Union([ENVIRONMENT_SCHEMA, t.Literal('all')]);
27
+
28
+ export const STATUS_SCHEMA = t.Union([
29
+ t.Literal('ok'),
30
+ t.Literal('needs_auth'),
31
+ t.Literal('needs_config'),
32
+ t.Literal('error'),
33
+ t.Literal('unknown')
34
+ ]);
35
+
36
+ export const DEPLOY_ACTION_SCHEMA = t.Union([
37
+ t.Literal('redeploy'),
38
+ t.Literal('cancel'),
39
+ t.Literal('rollback'),
40
+ t.Literal('promote'),
41
+ t.Literal('delete')
42
+ ]);
43
+
44
+ export const RATE_LIMIT_SCHEMA = t.Object({
45
+ remaining: t.Number(),
46
+ limit: t.Number(),
47
+ resetAt: t.Union([t.String(), t.Null()])
48
+ });
49
+
50
+ export const DEPLOYMENT_SCHEMA = t.Object({
51
+ id: t.String(),
52
+ name: t.String(),
53
+ url: t.Union([t.String(), t.Null()]),
54
+ inspectorUrl: t.Union([t.String(), t.Null()]),
55
+ state: DEPLOYMENT_STATE_SCHEMA,
56
+ stateDetail: t.String(),
57
+ environment: ENVIRONMENT_SCHEMA,
58
+ isCurrent: t.Boolean(),
59
+ isRollbackCandidate: t.Union([t.Boolean(), t.Null()]),
60
+ branch: t.Union([t.String(), t.Null()]),
61
+ commitSha: t.Union([t.String(), t.Null()]),
62
+ commitMessage: t.Union([t.String(), t.Null()]),
63
+ creator: t.Union([t.String(), t.Null()]),
64
+ createdAt: t.String(),
65
+ buildingAt: t.Union([t.String(), t.Null()]),
66
+ readyAt: t.Union([t.String(), t.Null()]),
67
+ errorCode: t.Union([t.String(), t.Null()]),
68
+ errorMessage: t.Union([t.String(), t.Null()]),
69
+ source: t.Union([t.String(), t.Null()])
70
+ });
71
+
72
+ export const DEPLOYMENT_DETAIL_SCHEMA = t.Composite([
73
+ DEPLOYMENT_SCHEMA,
74
+ t.Object({
75
+ aliases: t.Array(t.String()),
76
+ framework: t.Union([t.String(), t.Null()]),
77
+ durationMs: t.Union([t.Number(), t.Null()])
78
+ })
79
+ ]);
80
+
81
+ export const DEPLOY_TARGET_SCHEMA = t.Object({
82
+ id: t.String(),
83
+ name: t.String(),
84
+ teamId: t.Union([t.String(), t.Null()]),
85
+ teamName: t.Union([t.String(), t.Null()]),
86
+ framework: t.Union([t.String(), t.Null()]),
87
+ gitRepo: t.Union([t.String(), t.Null()])
88
+ });
89
+
90
+ export const DEPLOY_CONFIG_SCHEMA = t.Object({
91
+ environment: ENVIRONMENT_FILTER_SCHEMA,
92
+ autoRefresh: t.Boolean()
93
+ });
94
+
95
+ export const DEPLOY_BINDING_SCHEMA = t.Object({
96
+ locator: t.String(),
97
+ displayName: t.String(),
98
+ detected: t.Boolean(),
99
+ teamId: t.Union([t.String(), t.Null()]),
100
+ config: DEPLOY_CONFIG_SCHEMA
101
+ });
102
+
103
+ export const DEPLOY_CAPABILITIES_SCHEMA = t.Object({
104
+ logs: t.Boolean(),
105
+ createDeployment: t.Boolean(),
106
+ createProject: t.Boolean(),
107
+ connectRepository: t.Boolean(),
108
+ deleteDeployment: t.Boolean(),
109
+ streamLogs: t.Boolean(),
110
+ redeploy: t.Boolean(),
111
+ cancel: t.Boolean(),
112
+ rollback: t.Boolean(),
113
+ promote: t.Boolean(),
114
+ environments: t.Boolean(),
115
+ branchFilter: t.Boolean()
116
+ });
117
+
118
+ export const DEPLOY_SOURCE_SCHEMA = t.Object({
119
+ accountId: t.String(),
120
+ provider: t.String(),
121
+ providerName: t.String(),
122
+ label: t.String(),
123
+ viewer: t.Union([t.String(), t.Null()]),
124
+ capabilities: DEPLOY_CAPABILITIES_SCHEMA,
125
+ binding: t.Union([DEPLOY_BINDING_SCHEMA, t.Null()]),
126
+ suggestedTargets: t.Array(DEPLOY_TARGET_SCHEMA),
127
+ status: STATUS_SCHEMA,
128
+ statusDetail: t.Union([t.String(), t.Null()])
129
+ });
130
+
131
+ export const LOG_BUNDLE_SCHEMA = t.Object({
132
+ deploymentId: t.String(),
133
+ text: t.String(),
134
+ truncated: t.Boolean()
135
+ });
136
+
137
+ export const ACTION_RESULT_SCHEMA = t.Object({
138
+ action: DEPLOY_ACTION_SCHEMA,
139
+ status: t.Union([t.Literal('done'), t.Literal('pending')]),
140
+ deploymentId: t.Union([t.String(), t.Null()]),
141
+ message: t.String()
142
+ });
143
+
144
+ export const DEPLOY_INFO_SCHEMA = t.Object({
145
+ gitRepo: t.Union([t.String(), t.Null()]),
146
+ productionBranch: t.Union([t.String(), t.Null()]),
147
+ canDeploy: t.Boolean(),
148
+ reason: t.Union([t.String(), t.Null()]),
149
+ suggestedRepo: t.Union([t.String(), t.Null()]),
150
+ connectState: t.Union([
151
+ t.Literal('ready'),
152
+ t.Literal('blocked'),
153
+ t.Literal('unknown'),
154
+ t.Literal('unavailable')
155
+ ]),
156
+ connectHint: t.Union([t.String(), t.Null()]),
157
+ connectUrl: t.Union([t.String(), t.Null()]),
158
+ currentBranch: t.Union([t.String(), t.Null()])
159
+ });
160
+
161
+ export const NEW_PROJECT_DEFAULTS_SCHEMA = t.Object({
162
+ suggestedName: t.String(),
163
+ gitRepo: t.Union([t.String(), t.Null()]),
164
+ gitProvider: t.Union([t.String(), t.Null()])
165
+ });
166
+
167
+ export const PROJECT_STATUS_SCHEMA = t.Object({
168
+ paused: t.Boolean(),
169
+ aliasRequest: t.Union([
170
+ t.Object({
171
+ type: t.Union([t.Literal('rollback'), t.Literal('promote')]),
172
+ status: t.Union([
173
+ t.Literal('pending'),
174
+ t.Literal('in-progress'),
175
+ t.Literal('succeeded'),
176
+ t.Literal('failed'),
177
+ t.Literal('skipped')
178
+ ]),
179
+ toDeploymentId: t.Union([t.String(), t.Null()])
180
+ }),
181
+ t.Null()
182
+ ])
183
+ });
@@ -47,6 +47,7 @@ import { memoryRouter } from './memory';
47
47
  import { worktreesRouter } from './worktrees';
48
48
  import { notesRouter } from './notes';
49
49
  import { workRouter } from './work';
50
+ import { deploymentsRouter } from './deployments';
50
51
 
51
52
  // ============================================
52
53
  // Main App Router - Merge All Module Routers
@@ -116,14 +117,17 @@ export const wsRouter = createRouter()
116
117
  .merge(profilesRouter)
117
118
  .merge(artifactsRouter)
118
119
 
119
- // Memory Graph (unified episodic + structural memory, shared by every engine)
120
+ // Memory Graph (one store of memories, shared by every engine)
120
121
  .merge(memoryRouter)
121
122
 
122
123
  // Notes (project-scoped markdown)
123
124
  .merge(notesRouter)
124
125
 
125
126
  // Issues & PRs surface — work items, pull requests and CI for the current project
126
- .merge(workRouter);
127
+ .merge(workRouter)
128
+
129
+ // Deployments surface — builds, logs and what is live, for the current project
130
+ .merge(deploymentsRouter);
127
131
 
128
132
  // Export API type for frontend type-safe access
129
133
  export type WSAPI = typeof wsRouter['$api'];
@@ -39,9 +39,8 @@ import { getMemoryReadiness } from '$backend/memory/readiness';
39
39
  import { reconcileVectorIndex } from '$backend/memory/indexer';
40
40
  import { ensureEmbeddingArtifact, embedder, vectorCache } from '$backend/memory/embedding';
41
41
  import type { EngineType } from '$shared/types/unified';
42
- import type { GraphNodeKind, GraphScope, GraphSource } from '$shared/types/memory';
42
+ import type { GraphScope, GraphSource } from '$shared/types/memory';
43
43
 
44
- const KIND = t.Union([t.Literal('episodic'), t.Literal('structural')]);
45
44
  const SCOPE = t.Union([t.Literal('session'), t.Literal('project'), t.Literal('global')]);
46
45
  const SOURCE = t.Union([t.Literal('agent'), t.Literal('user')]);
47
46
  const EPISODIC_SUBKIND = t.Union([
@@ -55,16 +54,14 @@ const EPISODIC_SUBKIND = t.Union([
55
54
 
56
55
  const NODE = t.Object({
57
56
  id: t.String(),
58
- kind: t.String(),
59
57
  subkind: t.String(),
60
58
  scope: t.String(),
61
59
  projectId: t.Union([t.String(), t.Null()]),
62
60
  sessionId: t.Union([t.String(), t.Null()]),
63
61
  label: t.String(),
64
62
  body: t.String(),
65
- path: t.Union([t.String(), t.Null()]),
66
- symbol: t.Union([t.String(), t.Null()]),
67
- language: t.Union([t.String(), t.Null()]),
63
+ /** Repo-relative paths this memory claims something about; see migration 076. */
64
+ relatedPaths: t.Optional(t.Array(t.String())),
68
65
  digest: t.String(),
69
66
  confidence: t.Number(),
70
67
  weight: t.Number(),
@@ -94,7 +91,6 @@ const MEMORY_MODEL = t.Object({
94
91
 
95
92
  const CONFIG = t.Object({
96
93
  enabled: t.Boolean(),
97
- recordCode: t.Boolean(),
98
94
  recordMemories: t.Boolean(),
99
95
  autoRecall: t.Boolean(),
100
96
  model: t.Union([MEMORY_MODEL, t.Null()])
@@ -171,7 +167,6 @@ export const memoryCrudHandler = createRouter()
171
167
  .http('memory:graph', {
172
168
  data: t.Object({
173
169
  projectIds: t.Optional(t.Array(t.String())),
174
- kinds: t.Optional(t.Array(KIND)),
175
170
  subkinds: t.Optional(t.Array(t.String())),
176
171
  scopes: t.Optional(t.Array(SCOPE)),
177
172
  sources: t.Optional(t.Array(SOURCE)),
@@ -193,7 +188,6 @@ export const memoryCrudHandler = createRouter()
193
188
  level: t.String(),
194
189
  nodes: t.Array(t.Object({
195
190
  id: t.String(),
196
- kind: t.String(),
197
191
  subkind: t.String(),
198
192
  scope: t.String(),
199
193
  label: t.String(),
@@ -248,7 +242,6 @@ export const memoryCrudHandler = createRouter()
248
242
  debug.log('path', 'memory:graph');
249
243
  return buildGraphView({
250
244
  projectIds: scopeForRole(conn, data.projectIds),
251
- kinds: data.kinds as GraphNodeKind[] | undefined,
252
245
  subkinds: data.subkinds,
253
246
  scopes: data.scopes as GraphScope[] | undefined,
254
247
  sources: data.sources as GraphSource[] | undefined,
@@ -273,7 +266,6 @@ export const memoryCrudHandler = createRouter()
273
266
  data: t.Object({
274
267
  query: t.String(),
275
268
  projectIds: t.Optional(t.Array(t.String())),
276
- kinds: t.Optional(t.Array(KIND)),
277
269
  subkinds: t.Optional(t.Array(t.String())),
278
270
  sources: t.Optional(t.Array(SOURCE)),
279
271
  limit: t.Optional(t.Number()),
@@ -303,7 +295,6 @@ export const memoryCrudHandler = createRouter()
303
295
  const result = retrieve({
304
296
  query: data.query,
305
297
  projectIds: scopeForRole(conn, data.projectIds),
306
- kinds: data.kinds as GraphNodeKind[] | undefined,
307
298
  subkinds: data.subkinds,
308
299
  sources: data.sources as GraphSource[] | undefined,
309
300
  limit: data.limit ?? 20,
@@ -330,8 +321,6 @@ export const memoryCrudHandler = createRouter()
330
321
  response: t.Object({
331
322
  nodes: t.Number(),
332
323
  edges: t.Number(),
333
- episodic: t.Number(),
334
- structural: t.Number(),
335
324
  vectors: t.Number(),
336
325
  byScope: t.Object({ session: t.Number(), project: t.Number(), global: t.Number() }),
337
326
  byProject: t.Array(t.Object({ projectId: t.Union([t.String(), t.Null()]), count: t.Number() })),
@@ -659,7 +648,7 @@ export const memoryCrudHandler = createRouter()
659
648
  .http('memory:save-config', {
660
649
  data: t.Object({
661
650
  enabled: t.Optional(t.Boolean()),
662
- recordCode: t.Optional(t.Boolean()),
651
+
663
652
  recordMemories: t.Optional(t.Boolean()),
664
653
  autoRecall: t.Optional(t.Boolean()),
665
654
  model: t.Optional(t.Union([MEMORY_MODEL, t.Null()]))
@@ -669,7 +658,6 @@ export const memoryCrudHandler = createRouter()
669
658
  debug.log('path', 'memory:save-config');
670
659
  return setMemoryConfig({
671
660
  ...(data.enabled !== undefined && { enabled: data.enabled }),
672
- ...(data.recordCode !== undefined && { recordCode: data.recordCode }),
673
661
  ...(data.recordMemories !== undefined && { recordMemories: data.recordMemories }),
674
662
  ...(data.autoRecall !== undefined && { autoRecall: data.autoRecall }),
675
663
  ...(data.model !== undefined && {
@@ -7,6 +7,7 @@
7
7
  * - crud.ts: HTTP endpoints for CRUD operations (list, create, get, update, delete)
8
8
  * - status.ts: Real-time status updates and watching (get-status, watch, unwatch, events)
9
9
  * - presence.ts: User presence management (update-presence with broadcast)
10
+ * - overview.ts: Per-project resource usage for every project (projects:overview)
10
11
  */
11
12
 
12
13
  import { createRouter } from '$shared/utils/ws-server';
@@ -14,6 +15,7 @@ import { crudHandler } from './crud';
14
15
  import { statusHandler } from './status';
15
16
  import { presenceHandler } from './presence';
16
17
  import { infoHandler } from './info';
18
+ import { overviewHandler } from './overview';
17
19
 
18
20
  export const projectsRouter = createRouter()
19
21
  // CRUD Operations (HTTP)
@@ -26,4 +28,7 @@ export const projectsRouter = createRouter()
26
28
  .merge(presenceHandler)
27
29
 
28
30
  // Per-project resource info (storage + process-isolated CPU/RAM)
29
- .merge(infoHandler);
31
+ .merge(infoHandler)
32
+
33
+ // Per-project resource usage across every project the caller can see
34
+ .merge(overviewHandler);
@@ -24,7 +24,9 @@ import { collectProcessTree, getHostFacts, getProcessTable } from '../../host/me
24
24
  const MAX_ENTRIES = 300_000;
25
25
  /** Wall-clock ceiling — the backstop for slow disks and network mounts. */
26
26
  const WALK_DEADLINE_MS = 15_000;
27
- /** How many `stat` calls are in flight at once while walking one directory. */
27
+ /** How many `stat` calls are in flight at once while walking one directory.
28
+ * Multiplied by the number of concurrent walks, so `MAX_BACKGROUND_WALKS`
29
+ * bounds the descriptor fan-out on platforms with a low `ulimit -n`. */
28
30
  const STAT_BATCH = 64;
29
31
  /** A folder's size changes slowly; a poll should not re-walk it every tick. */
30
32
  const STORAGE_CACHE_TTL_MS = 15_000;
@@ -37,7 +39,7 @@ const PORTS_CACHE_TTL_MS = 5_000;
37
39
 
38
40
  // ── Storage ──────────────────────────────────────────────────────────────────
39
41
 
40
- interface FolderStats {
42
+ export interface FolderStats {
41
43
  sizeBytes: number;
42
44
  fileCount: number;
43
45
  dirCount: number;
@@ -49,7 +51,9 @@ const storageCache = new Map<string, { stats: FolderStats; at: number; ttl: numb
49
51
  const storageInFlight = new Map<string, Promise<FolderStats>>();
50
52
 
51
53
  /** Cached and single-flighted: a big walk outlives the poll interval, so a
52
- * result-only cache would let every tick start another one. */
54
+ * result-only cache would let every tick start another one. Callers that
55
+ * cannot afford the wait go through `peekFolderStats()` below, which shares
56
+ * this cache and this in-flight guard. */
53
57
  function getFolderStats(root: string): Promise<FolderStats> {
54
58
  const cached = storageCache.get(root);
55
59
  if (cached && Date.now() - cached.at < cached.ttl) {
@@ -83,6 +87,61 @@ function getFolderStats(root: string): Promise<FolderStats> {
83
87
  return walk;
84
88
  }
85
89
 
90
+ /** Walk slots for callers that ask about every project at once.
91
+ *
92
+ * One walk already keeps `STAT_BATCH` `stat` calls in flight; fanning out
93
+ * unbounded multiplies that by the project count, which is how a 20-project
94
+ * install reaches thousands of open descriptors — past the 256 soft limit
95
+ * macOS hands a GUI-launched process. */
96
+ const MAX_BACKGROUND_WALKS = 4;
97
+ let runningBackgroundWalks = 0;
98
+ const queuedWalks: string[] = [];
99
+ const queuedWalkPaths = new Set<string>();
100
+
101
+ function pumpBackgroundWalks(): void {
102
+ while (runningBackgroundWalks < MAX_BACKGROUND_WALKS && queuedWalks.length > 0) {
103
+ const root = queuedWalks.shift() as string;
104
+ queuedWalkPaths.delete(root);
105
+ runningBackgroundWalks++;
106
+ // `getFolderStats` turns walk failures into error stats, so a rejection
107
+ // here is a programming fault, not a slow disk — swallow it and free
108
+ // the slot either way.
109
+ void getFolderStats(root)
110
+ .catch((error) => {
111
+ debug.warn('project', 'background folder walk failed:', error);
112
+ })
113
+ .finally(() => {
114
+ runningBackgroundWalks--;
115
+ pumpBackgroundWalks();
116
+ });
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Last known stats for a folder, never a wait.
122
+ *
123
+ * `getFolderStats` blocks for the whole walk on a cold cache, which is right
124
+ * for `projects:info` (one folder, one modal) and wrong for `projects:overview`
125
+ * (every folder, polled). The overview would hold its request open for the full
126
+ * walk deadline on first open — exactly the long skeleton this panel exists to
127
+ * avoid. Instead, callers get the previous answer immediately (`null` before
128
+ * the first walk ever finished) and a refresh is queued behind a bounded pool.
129
+ */
130
+ export function peekFolderStats(root: string): FolderStats | null {
131
+ const cached = storageCache.get(root);
132
+ if (cached && Date.now() - cached.at < cached.ttl) return cached.stats;
133
+
134
+ if (!storageInFlight.has(root) && !queuedWalkPaths.has(root)) {
135
+ queuedWalkPaths.add(root);
136
+ queuedWalks.push(root);
137
+ pumpBackgroundWalks();
138
+ }
139
+
140
+ // Stale beats empty: the size a project had a minute ago is still the right
141
+ // order of magnitude, and the next poll replaces it.
142
+ return cached?.stats ?? null;
143
+ }
144
+
86
145
  async function walkFolder(root: string): Promise<FolderStats> {
87
146
  try {
88
147
  const rootStat = await stat(root);
@@ -149,7 +208,7 @@ async function walkFolder(root: string): Promise<FolderStats> {
149
208
 
150
209
  // ── Per-project slice of the host process table ──────────────────────────────
151
210
 
152
- interface ProjectProcess {
211
+ export interface ProjectProcess {
153
212
  pid: number;
154
213
  parentPid: number;
155
214
  name: string;
@@ -158,7 +217,7 @@ interface ProjectProcess {
158
217
  command: string;
159
218
  }
160
219
 
161
- interface ProcessStats {
220
+ export interface ProcessStats {
162
221
  status: 'running' | 'not_running';
163
222
  cpuPercent: number | null;
164
223
  memRssBytes: number | null;
@@ -178,7 +237,12 @@ const IDLE: ProcessStats = {
178
237
  rootPids: []
179
238
  };
180
239
 
181
- async function getProjectProcessStats(projectId: string, totalMemBytes: number): Promise<ProcessStats> {
240
+ /**
241
+ * Exported for reuse by `projects:overview` so per-project CPU/RAM there is
242
+ * measured exactly the way `projects:info` measures it — same roots, same
243
+ * shared process table, same capacity basis. No behavior change for callers.
244
+ */
245
+ export async function getProjectProcessStats(projectId: string, totalMemBytes: number): Promise<ProcessStats> {
182
246
  const rootPids = projectShellPids(projectId);
183
247
 
184
248
  // No shells means nothing is running, so zero is the truth here.