@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,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 && {