@vellumai/assistant 0.10.7-dev.202607100313.fffdfea → 0.10.7-dev.202607100720.fba456e

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 (99) hide show
  1. package/openapi.yaml +846 -27
  2. package/package.json +1 -1
  3. package/src/__tests__/config-watcher-skill-reseed.test.ts +1 -0
  4. package/src/__tests__/config-watcher.test.ts +22 -4
  5. package/src/__tests__/credential-security-invariants.test.ts +1 -1
  6. package/src/__tests__/plugin-import-boundary-guard.test.ts +6 -9
  7. package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +0 -2
  8. package/src/cli/commands/__tests__/inference-models.test.ts +86 -0
  9. package/src/cli/commands/__tests__/inference-profiles.test.ts +254 -0
  10. package/src/cli/commands/__tests__/inference-providers.test.ts +171 -0
  11. package/src/cli/commands/__tests__/schedules.test.ts +133 -1
  12. package/src/cli/commands/__tests__/usage.test.ts +131 -0
  13. package/src/cli/commands/inference-callsites.ts +158 -0
  14. package/src/cli/commands/inference-models.ts +84 -0
  15. package/src/cli/commands/inference-profiles.ts +371 -0
  16. package/src/cli/commands/inference-providers-default.ts +89 -0
  17. package/src/cli/commands/inference-providers.ts +87 -16
  18. package/src/cli/commands/inference.ts +6 -0
  19. package/src/cli/commands/memory/nodes.ts +90 -50
  20. package/src/cli/commands/schedules.ts +17 -2
  21. package/src/cli/commands/usage.ts +59 -21
  22. package/src/cli/lib/__tests__/cli-output.test.ts +20 -0
  23. package/src/cli/lib/cli-output.ts +55 -0
  24. package/src/config/__tests__/loader-last-known-good.test.ts +229 -0
  25. package/src/config/__tests__/loader-sparse-array-cleanup.test.ts +166 -0
  26. package/src/config/default-profile-catalog.ts +28 -0
  27. package/src/config/loader.ts +276 -46
  28. package/src/daemon/config-watcher.ts +65 -20
  29. package/src/daemon/message-types/sync.ts +1 -0
  30. package/src/oauth/byo-connection.test.ts +1 -1
  31. package/src/oauth/connection-resolver.test.ts +140 -0
  32. package/src/oauth/connection-resolver.ts +48 -12
  33. package/src/plugins/defaults/memory/anisotropy.ts +1 -1
  34. package/src/plugins/defaults/memory/config.ts +1 -1
  35. package/src/plugins/defaults/memory/context-search/agent-protocol.ts +1 -1
  36. package/src/plugins/defaults/memory/context-search/search.ts +1 -1
  37. package/src/plugins/defaults/memory/graph/bootstrap.ts +1 -1
  38. package/src/plugins/defaults/memory/graph/consolidation.ts +1 -1
  39. package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +11 -1
  40. package/src/plugins/defaults/memory/graph/extraction.ts +1 -1
  41. package/src/plugins/defaults/memory/graph/narrative.ts +1 -1
  42. package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -1
  43. package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -1
  44. package/src/plugins/defaults/memory/graph/tools.ts +1 -1
  45. package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +43 -16
  46. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +1 -1
  47. package/src/plugins/defaults/memory/host-utils.ts +80 -0
  48. package/src/plugins/defaults/memory/identity-context.ts +1 -1
  49. package/src/plugins/defaults/memory/injectors.ts +1 -1
  50. package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +2 -2
  51. package/src/plugins/defaults/memory/jobs-worker.ts +2 -9
  52. package/src/plugins/defaults/memory/memory-retrospective-state.ts +1 -1
  53. package/src/plugins/defaults/memory/paths.ts +48 -0
  54. package/src/plugins/defaults/memory/pkb/autoinject.ts +1 -1
  55. package/src/plugins/defaults/memory/pkb/context.ts +2 -2
  56. package/src/plugins/defaults/memory/pkb/types.ts +1 -1
  57. package/src/plugins/defaults/memory/pkb-schedule.ts +2 -2
  58. package/src/plugins/defaults/memory/rerank-local.ts +2 -3
  59. package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
  60. package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +149 -1
  61. package/src/plugins/defaults/memory/routes/memory-item-routes.ts +144 -1
  62. package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
  63. package/src/plugins/defaults/memory/startup.ts +1 -1
  64. package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
  65. package/src/plugins/defaults/memory/v2/consolidation-job.ts +2 -2
  66. package/src/plugins/defaults/memory/v2/injection.ts +1 -1
  67. package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
  68. package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
  69. package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
  70. package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
  71. package/src/plugins/defaults/memory/v2/static-context.ts +1 -1
  72. package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
  73. package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
  74. package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
  75. package/src/plugins/defaults/memory/v3/page-content.ts +1 -1
  76. package/src/plugins/defaults/memory/v3/pool-select.ts +1 -2
  77. package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
  78. package/src/plugins/defaults/memory/v3/shadow-plugin.ts +2 -5
  79. package/src/plugins/defaults/memory/worker.ts +1 -1
  80. package/src/plugins/defaults/workspace/injectors.ts +17 -15
  81. package/src/plugins/types.ts +9 -14
  82. package/src/providers/inference/connection-availability.ts +193 -0
  83. package/src/runtime/routes/__tests__/inference-callsites-routes.test.ts +54 -0
  84. package/src/runtime/routes/__tests__/inference-models-routes.test.ts +54 -0
  85. package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +405 -0
  86. package/src/runtime/routes/__tests__/inference-routes-registration.test.ts +42 -0
  87. package/src/runtime/routes/__tests__/theme-routes.test.ts +66 -0
  88. package/src/runtime/routes/conversation-query-routes.ts +5 -3
  89. package/src/runtime/routes/default-provider-routes.ts +5 -152
  90. package/src/runtime/routes/index.ts +8 -0
  91. package/src/runtime/routes/inference-callsites-routes.ts +211 -0
  92. package/src/runtime/routes/inference-models-routes.ts +104 -0
  93. package/src/runtime/routes/inference-profiles-routes.ts +717 -0
  94. package/src/runtime/routes/theme-routes.ts +36 -0
  95. package/src/runtime/sync/resource-sync-events.ts +4 -0
  96. package/src/theme/workspace-theme.test.ts +269 -0
  97. package/src/theme/workspace-theme.ts +304 -0
  98. package/src/watcher/__tests__/engine-auth-notify.test.ts +316 -0
  99. package/src/watcher/engine.ts +87 -2
@@ -53,22 +53,15 @@ import {
53
53
  SLOW_LLM_JOB_TYPES,
54
54
  } from "../../../persistence/jobs-store.js";
55
55
  import { spawnMemoryWorkerProcess } from "../../../persistence/worker-control.js";
56
- import { getWorkspaceDir } from "../../../util/platform.js";
56
+ import type { JobHandler } from "../../types.js";
57
57
  import { getLogger } from "./logging.js";
58
58
  import { sweepOrphanMemoryRetrospectiveConversations } from "./memory-retrospective-startup-cleanup.js";
59
+ import { getWorkspaceDir } from "./paths.js";
59
60
  import { hasPkbBufferContent } from "./pkb-schedule.js";
60
61
  import { countBufferLines } from "./v2/consolidation-job.js";
61
62
 
62
63
  const log = getLogger("memory-jobs-worker");
63
64
 
64
- /**
65
- * A per-job-type handler. The owning feature (e.g. memory) registers handlers
66
- * via {@link registerJobHandler}; the worker dispatches each claimed job to its
67
- * registered handler. Decoupling registration from the worker keeps the queue
68
- * mechanics generic and free of feature-specific handler imports.
69
- */
70
- export type JobHandler = (job: MemoryJob, config: AssistantConfig) => unknown;
71
-
72
65
  const jobHandlers = new Map<string, JobHandler>();
73
66
 
74
67
  /**
@@ -27,7 +27,7 @@ import { eq } from "drizzle-orm";
27
27
 
28
28
  import { type DrizzleDb, getDb } from "../../../persistence/db-connection.js";
29
29
  import { memoryRetrospectiveState } from "../../../persistence/schema/index.js";
30
- import { withSqliteRetry } from "../../../util/sqlite-retry.js";
30
+ import { withSqliteRetry } from "./host-utils.js";
31
31
 
32
32
  export interface MemoryRetrospectiveState {
33
33
  conversationId: string;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The memory plugin's single host-path channel. Every module in this plugin
3
+ * resolves filesystem locations here rather than importing host
4
+ * `util/platform` directly, so the host import below is the plugin's sole
5
+ * path escape (tracked by `plugin-import-boundary-guard.test.ts`), mirroring
6
+ * `logging.ts`.
7
+ *
8
+ * A plain forward is deliberate: `@vellumai/plugin-api` has no workspace-dir
9
+ * facet today (identity facets take the workspace dir as a parameter), and
10
+ * these resolvers also run inside the jobs worker and CLI processes where no
11
+ * plugin bootstrap exists. Centralizing the import keeps a future cutover —
12
+ * a paths facet on the contract, or `InitContext`-provided roots — a
13
+ * one-file change. `getMemoryWorkerPidPath` is the PID-file coordination
14
+ * point shared with the host spawn/status paths (`persistence/worker-control`,
15
+ * `runtime/routes/memory-worker-routes`), so it must stay host-defined.
16
+ */
17
+ // A namespace import (not named imports) so tests that mock `util/platform`
18
+ // with a subset of its exports don't fail this module's import link — each
19
+ // forward resolves its function at call time.
20
+ import * as hostPlatform from "../../../util/platform.js";
21
+
22
+ export function getWorkspaceDir(): string {
23
+ return hostPlatform.getWorkspaceDir();
24
+ }
25
+
26
+ export function getWorkspacePromptPath(file: string): string {
27
+ return hostPlatform.getWorkspacePromptPath(file);
28
+ }
29
+
30
+ export function getWorkspaceConfigPath(): string {
31
+ return hostPlatform.getWorkspaceConfigPath();
32
+ }
33
+
34
+ export function getDataDir(): string {
35
+ return hostPlatform.getDataDir();
36
+ }
37
+
38
+ export function getSandboxWorkingDir(): string {
39
+ return hostPlatform.getSandboxWorkingDir();
40
+ }
41
+
42
+ export function getEmbeddingModelsDir(): string {
43
+ return hostPlatform.getEmbeddingModelsDir();
44
+ }
45
+
46
+ export function getMemoryWorkerPidPath(): string {
47
+ return hostPlatform.getMemoryWorkerPidPath();
48
+ }
@@ -10,7 +10,7 @@
10
10
  import { existsSync, readFileSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
 
13
- import { stripCommentLines } from "../../../../util/strip-comment-lines.js";
13
+ import { stripCommentLines } from "../host-utils.js";
14
14
 
15
15
  const PKB_DEFAULT_FILES = [
16
16
  "INDEX.md",
@@ -1,8 +1,8 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
 
4
- import { getWorkspaceDir } from "../../../../util/platform.js";
5
- import { stripCommentLines } from "../../../../util/strip-comment-lines.js";
4
+ import { stripCommentLines } from "../host-utils.js";
5
+ import { getWorkspaceDir } from "../paths.js";
6
6
  import { getPkbAutoInjectList } from "./autoinject.js";
7
7
 
8
8
  /** Max buffer.md lines injected into prompts — keeps context bounded even when filing is off. */
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { join } from "node:path";
9
9
 
10
- import { getWorkspaceDir } from "../../../../util/platform.js";
10
+ import { getWorkspaceDir } from "../paths.js";
11
11
 
12
12
  export const PKB_TARGET_TYPE = "pkb_file" as const;
13
13
 
@@ -10,8 +10,8 @@
10
10
  import { existsSync, readFileSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
 
13
- import { getWorkspaceDir } from "../../../util/platform.js";
14
- import { stripCommentLines } from "../../../util/strip-comment-lines.js";
13
+ import { stripCommentLines } from "./host-utils.js";
14
+ import { getWorkspaceDir } from "./paths.js";
15
15
 
16
16
  /**
17
17
  * Whether `pkb/buffer.md` has any filable content (comment lines and
@@ -3,10 +3,9 @@ import { existsSync } from "node:fs";
3
3
 
4
4
  import type { RerankDtype } from "../../../config/schemas/memory-v2.js";
5
5
  import { EmbeddingRuntimeManager } from "../../../persistence/embeddings/embedding-runtime-manager.js";
6
- import { getEmbeddingModelsDir } from "../../../util/platform.js";
7
- import { PromiseGuard } from "../../../util/promise-guard.js";
8
- import { workerMemoryEnv } from "../../../util/worker-memory.js";
6
+ import { PromiseGuard, workerMemoryEnv } from "./host-utils.js";
9
7
  import { getLogger } from "./logging.js";
8
+ import { getEmbeddingModelsDir } from "./paths.js";
10
9
 
11
10
  const log = getLogger("memory-rerank-local");
12
11
 
@@ -20,8 +20,8 @@ import {
20
20
  type RoutePolicy,
21
21
  } from "../../../../runtime/auth/route-policy.js";
22
22
  import type { RouteDefinition } from "../../../../runtime/routes/types.js";
23
- import { getWorkspaceDir } from "../../../../util/platform.js";
24
23
  import { getLogger } from "../logging.js";
24
+ import { getWorkspaceDir } from "../paths.js";
25
25
  import { runMemoryEval } from "../v3-eval/eval-packets.js";
26
26
  import { type TallyResult, tallyVerdicts } from "../v3-eval/eval-tally.js";
27
27
 
@@ -4,7 +4,15 @@
4
4
  * Covers: list with filters, get by ID, create + duplicate rejection,
5
5
  * update + fingerprint collision, delete + 404.
6
6
  */
7
- import { beforeAll, beforeEach, describe, expect, mock, test } from "bun:test";
7
+ import {
8
+ afterEach,
9
+ beforeAll,
10
+ beforeEach,
11
+ describe,
12
+ expect,
13
+ mock,
14
+ test,
15
+ } from "bun:test";
8
16
 
9
17
  mock.module("../../../../util/logger.js", () => ({
10
18
  getLogger: () =>
@@ -918,4 +926,144 @@ describe("Memory Item Routes", () => {
918
926
  expect(payload.targetId).toBe("i1");
919
927
  });
920
928
  });
929
+ // ── Memory nodes (content-addressed) ──────────────────────────────────────
930
+
931
+ describe("memory nodes routes", () => {
932
+ const cfg = mockConfig as { memory: { v2: { enabled: boolean } } };
933
+
934
+ beforeEach(() => {
935
+ cfg.memory.v2.enabled = true;
936
+ });
937
+
938
+ afterEach(() => {
939
+ cfg.memory.v2.enabled = false;
940
+ });
941
+
942
+ interface NodesListBody {
943
+ success: boolean;
944
+ message: string;
945
+ nodes: Array<{ id: string; content: string }>;
946
+ total: number;
947
+ }
948
+
949
+ interface NodesMutationBody {
950
+ success: boolean;
951
+ message: string;
952
+ }
953
+
954
+ test("listMemoryNodes lists seeded nodes and filters by search", async () => {
955
+ insertItem({
956
+ id: "n1",
957
+ type: "semantic",
958
+ content: "User prefers TypeScript",
959
+ significance: 0.9,
960
+ });
961
+ insertItem({
962
+ id: "n2",
963
+ type: "episodic",
964
+ content: "User visited Springfield",
965
+ significance: 0.5,
966
+ });
967
+
968
+ const route = getRoute("memory-nodes", "GET");
969
+ const all = (await (
970
+ await callHandler(route, { queryParams: {} })
971
+ ).json()) as NodesListBody;
972
+ expect(all.success).toBe(true);
973
+ expect(all.total).toBe(2);
974
+
975
+ const filtered = (await (
976
+ await callHandler(route, {
977
+ queryParams: { search: "TypeScript", limit: "10" },
978
+ })
979
+ ).json()) as NodesListBody;
980
+ expect(filtered.success).toBe(true);
981
+ expect(filtered.nodes.map((n) => n.id)).toEqual(["n1"]);
982
+ });
983
+
984
+ test("listMemoryNodes reports memory v2 disabled as a business failure", async () => {
985
+ cfg.memory.v2.enabled = false;
986
+ const body = (await (
987
+ await callHandler(getRoute("memory-nodes", "GET"), { queryParams: {} })
988
+ ).json()) as NodesListBody;
989
+ expect(body.success).toBe(false);
990
+ expect(body.message.length).toBeGreaterThan(0);
991
+ });
992
+
993
+ test("deleteMemoryNode deletes the node matching exact content", async () => {
994
+ insertItem({
995
+ id: "n1",
996
+ type: "semantic",
997
+ content: "User prefers TypeScript",
998
+ });
999
+
1000
+ const body = (await (
1001
+ await callHandler(getRoute("memory-nodes/delete", "POST"), {
1002
+ body: { content: "User prefers TypeScript" },
1003
+ })
1004
+ ).json()) as NodesMutationBody;
1005
+ expect(body.success).toBe(true);
1006
+
1007
+ const after = (await (
1008
+ await callHandler(getRoute("memory-nodes", "GET"), { queryParams: {} })
1009
+ ).json()) as NodesListBody;
1010
+ expect(after.nodes.map((n) => n.id)).not.toContain("n1");
1011
+ });
1012
+
1013
+ test("listMemoryNodes rejects a non-numeric limit as 400", async () => {
1014
+ const res = await callHandler(getRoute("memory-nodes", "GET"), {
1015
+ queryParams: { limit: "abc" },
1016
+ });
1017
+ expect(res.status).toBe(400);
1018
+ });
1019
+
1020
+ test("deleteMemoryNode rejects a missing content body as 400", async () => {
1021
+ const res = await callHandler(getRoute("memory-nodes/delete", "POST"), {
1022
+ body: {},
1023
+ });
1024
+ expect(res.status).toBe(400);
1025
+ });
1026
+
1027
+ test("updateMemoryNode rejects a non-string body field as 400", async () => {
1028
+ const res = await callHandler(getRoute("memory-nodes/update", "POST"), {
1029
+ body: { oldContent: "x", newContent: 42 },
1030
+ });
1031
+ expect(res.status).toBe(400);
1032
+ });
1033
+
1034
+ test("deleteMemoryNode fails as data when nothing matches", async () => {
1035
+ const body = (await (
1036
+ await callHandler(getRoute("memory-nodes/delete", "POST"), {
1037
+ body: { content: "does not exist anywhere" },
1038
+ })
1039
+ ).json()) as NodesMutationBody;
1040
+ expect(body.success).toBe(false);
1041
+ expect(body.message.length).toBeGreaterThan(0);
1042
+ });
1043
+
1044
+ test("updateMemoryNode replaces content on the exact-match node", async () => {
1045
+ insertItem({
1046
+ id: "n1",
1047
+ type: "semantic",
1048
+ content: "User prefers TypeScript",
1049
+ });
1050
+
1051
+ const body = (await (
1052
+ await callHandler(getRoute("memory-nodes/update", "POST"), {
1053
+ body: {
1054
+ oldContent: "User prefers TypeScript",
1055
+ newContent: "User prefers TypeScript and Bun",
1056
+ },
1057
+ })
1058
+ ).json()) as NodesMutationBody;
1059
+ expect(body.success).toBe(true);
1060
+
1061
+ const after = (await (
1062
+ await callHandler(getRoute("memory-nodes", "GET"), { queryParams: {} })
1063
+ ).json()) as NodesListBody;
1064
+ expect(after.nodes.map((n) => n.content)).toContain(
1065
+ "User prefers TypeScript and Bun",
1066
+ );
1067
+ });
1068
+ });
921
1069
  });
@@ -9,6 +9,13 @@
9
9
  * POST /v1/memory-items — create a new memory item
10
10
  * PATCH /v1/memory-items/:id — update an existing memory item
11
11
  * DELETE /v1/memory-items/:id — delete a memory item and its embeddings
12
+ *
13
+ * Plus the content-addressed "memory nodes" operator surface over the same
14
+ * graph (see the section in ROUTES):
15
+ *
16
+ * GET /v1/memory-nodes — list nodes (significance-ordered, content search)
17
+ * POST /v1/memory-nodes/delete — delete the single node matching content
18
+ * POST /v1/memory-nodes/update — replace content on the single node matching content
12
19
  */
13
20
 
14
21
  import {
@@ -46,6 +53,11 @@ import {
46
53
  import type { RouteDefinition } from "../../../../runtime/routes/types.js";
47
54
  import { embedWithBackend } from "../embeddings.js";
48
55
  import { createNode, deleteNode, getNode, updateNode } from "../graph/store.js";
56
+ import {
57
+ handleDeleteMemory,
58
+ handleListMemory,
59
+ handleUpdateMemory,
60
+ } from "../graph/tool-handlers.js";
49
61
  import type {
50
62
  Fidelity,
51
63
  ImageRef,
@@ -272,7 +284,9 @@ async function handleListMemoryItems(queryParams: Record<string, string>) {
272
284
 
273
285
  if (!isValidSortField(sortParam)) {
274
286
  throw new BadRequestError(
275
- `Invalid sort "${sortParam}". Must be one of: ${VALID_SORT_FIELDS.join(", ")}`,
287
+ `Invalid sort "${sortParam}". Must be one of: ${VALID_SORT_FIELDS.join(
288
+ ", ",
289
+ )}`,
276
290
  );
277
291
  }
278
292
 
@@ -803,4 +817,133 @@ export const ROUTES: RouteDefinition[] = [
803
817
  tags: ["memory"],
804
818
  handler: ({ pathParams }) => handleDeleteMemoryItem(pathParams!.id),
805
819
  },
820
+
821
+ // ── Memory nodes (content-addressed) ───────────────────────────────────────
822
+ // Operator surface over raw graph nodes addressed by content text rather
823
+ // than UUID, mirroring how the model-facing memory tools address them. The
824
+ // handlers return business failures ({ success: false, message }) as data —
825
+ // the same shape the memory tools hand the model — so callers branch on
826
+ // `success` instead of catching transport errors.
827
+
828
+ {
829
+ operationId: "listMemoryNodes",
830
+ endpoint: "memory-nodes",
831
+ method: "GET",
832
+ policy: {
833
+ requiredScopes: ["settings.read"],
834
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
835
+ },
836
+ summary: "List memory graph nodes",
837
+ description:
838
+ "Return active memory graph nodes ordered by significance. With `search`, all nodes are scanned so the content filter is exhaustive; without it the query is capped at `limit` rows.",
839
+ tags: ["memory"],
840
+ queryParams: [
841
+ {
842
+ name: "search",
843
+ schema: { type: "string" },
844
+ description: "Filter nodes whose content contains the query",
845
+ },
846
+ {
847
+ name: "limit",
848
+ schema: { type: "integer" },
849
+ description: "Max results (default 50, max 200)",
850
+ },
851
+ ],
852
+ responseBody: z.object({
853
+ success: z.boolean(),
854
+ message: z.string(),
855
+ nodes: z.array(
856
+ z.object({
857
+ id: z.string(),
858
+ content: z.string(),
859
+ type: z.string(),
860
+ fidelity: z.string(),
861
+ created: z.number(),
862
+ }),
863
+ ),
864
+ total: z.number(),
865
+ }),
866
+ handler: ({ queryParams }) => {
867
+ const limitRaw = queryParams?.limit;
868
+ let limit: number | undefined;
869
+ if (limitRaw) {
870
+ limit = Number.parseInt(limitRaw, 10);
871
+ if (!Number.isFinite(limit)) {
872
+ throw new BadRequestError("limit must be an integer");
873
+ }
874
+ }
875
+ return handleListMemory(
876
+ { search: queryParams?.search, limit },
877
+ getConfig(),
878
+ );
879
+ },
880
+ },
881
+
882
+ {
883
+ operationId: "deleteMemoryNode",
884
+ endpoint: "memory-nodes/delete",
885
+ method: "POST",
886
+ policy: {
887
+ requiredScopes: ["settings.write"],
888
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
889
+ },
890
+ summary: "Delete a memory graph node by content match",
891
+ description:
892
+ "Delete the single memory graph node matching `content`: a case-insensitive exact match takes priority; with no exact match, a substring match is tried. Fails as `{ success: false }` when zero or multiple nodes match.",
893
+ tags: ["memory"],
894
+ requestBody: z.object({
895
+ content: z.string(),
896
+ }),
897
+ responseBody: z.object({
898
+ success: z.boolean(),
899
+ message: z.string(),
900
+ }),
901
+ handler: ({ body }) => {
902
+ const parsed = z.object({ content: z.string() }).safeParse(body ?? {});
903
+ if (!parsed.success) {
904
+ throw new BadRequestError("content (string) is required");
905
+ }
906
+ return handleDeleteMemory({ content: parsed.data.content }, getConfig());
907
+ },
908
+ },
909
+
910
+ {
911
+ operationId: "updateMemoryNode",
912
+ endpoint: "memory-nodes/update",
913
+ method: "POST",
914
+ policy: {
915
+ requiredScopes: ["settings.write"],
916
+ allowedPrincipalTypes: ACTOR_PRINCIPALS,
917
+ },
918
+ summary: "Update a memory graph node by content match",
919
+ description:
920
+ "Replace the content of the single memory graph node matching `oldContent`: a case-insensitive exact match takes priority; with no exact match, a substring match is tried. Fails as `{ success: false }` when zero or multiple nodes match, or when another active node already has `newContent`.",
921
+ tags: ["memory"],
922
+ requestBody: z.object({
923
+ oldContent: z.string(),
924
+ newContent: z.string(),
925
+ }),
926
+ responseBody: z.object({
927
+ success: z.boolean(),
928
+ message: z.string(),
929
+ }),
930
+ handler: ({ body }) => {
931
+ const parsed = z
932
+ .object({ oldContent: z.string(), newContent: z.string() })
933
+ .safeParse(body ?? {});
934
+ if (!parsed.success) {
935
+ throw new BadRequestError(
936
+ "oldContent and newContent (strings) are required",
937
+ );
938
+ }
939
+ return handleUpdateMemory(
940
+ {
941
+ old_content: parsed.data.oldContent,
942
+ new_content: parsed.data.newContent,
943
+ },
944
+ "cli",
945
+ getConfig(),
946
+ );
947
+ },
948
+ },
806
949
  ];
@@ -19,12 +19,12 @@ import { ACTOR_PRINCIPALS } from "../../../../runtime/auth/route-policy.js";
19
19
  import { RouteError } from "../../../../runtime/routes/errors.js";
20
20
  import type { RouteDefinition } from "../../../../runtime/routes/types.js";
21
21
  import type { RouteHandlerArgs } from "../../../../runtime/routes/types.js";
22
- import { getWorkspaceDir } from "../../../../util/platform.js";
23
22
  import { getLogger } from "../logging.js";
24
23
  import {
25
24
  type ConceptFrequencyResponse,
26
25
  getConceptFrequencySummary,
27
26
  } from "../memory-v2-concept-frequency.js";
27
+ import { getWorkspaceDir } from "../paths.js";
28
28
  import {
29
29
  getEdgeIndex,
30
30
  totalEdgeCount,
@@ -33,10 +33,10 @@ import {
33
33
  enqueueMemoryJob,
34
34
  isMemoryEnabled,
35
35
  } from "../../../persistence/jobs-store.js";
36
- import { getWorkspaceDir } from "../../../util/platform.js";
37
36
  import { resolveQdrantUrl } from "./embeddings.js";
38
37
  import { startMemoryJobsWorker } from "./jobs-worker.js";
39
38
  import { getLogger } from "./logging.js";
39
+ import { getWorkspaceDir } from "./paths.js";
40
40
  import { sweepConceptPageFrontmatter } from "./v2/frontmatter-sweep.js";
41
41
  import {
42
42
  maybeRebuildMemoryV2Concepts,
@@ -27,9 +27,9 @@ import {
27
27
  import type { AssistantConfig } from "../../../../config/types.js";
28
28
  import { getDb } from "../../../../persistence/db-connection.js";
29
29
  import type { MemoryJob } from "../../../../persistence/jobs-store.js";
30
- import { getWorkspaceDir } from "../../../../util/platform.js";
31
30
  import { enqueueEmbedConceptPageJob } from "../jobs/embed-concept-page.js";
32
31
  import { getLogger } from "../logging.js";
32
+ import { getWorkspaceDir } from "../paths.js";
33
33
  import {
34
34
  computeOwnActivation,
35
35
  selectCandidates,
@@ -75,10 +75,10 @@ import {
75
75
  type MemoryJobType,
76
76
  } from "../../../../persistence/jobs-store.js";
77
77
  import { runBackgroundJob } from "../../../../runtime/background-job-runner.js";
78
- import { getWorkspaceDir } from "../../../../util/platform.js";
79
- import { isProcessAlive } from "../../../../util/process-liveness.js";
80
78
  import { formatBufferTimestamp } from "../graph/tool-handlers.js";
79
+ import { isProcessAlive } from "../host-utils.js";
81
80
  import { getLogger } from "../logging.js";
81
+ import { getWorkspaceDir } from "../paths.js";
82
82
  import { MEMORY_V2_CONSOLIDATION_SOURCE } from "./constants.js";
83
83
  import { resolveConsolidationPrompt } from "./prompts/consolidation.js";
84
84
 
@@ -25,12 +25,12 @@
25
25
 
26
26
  import type { AssistantConfig } from "../../../../config/types.js";
27
27
  import type { DrizzleDb } from "../../../../persistence/db-connection.js";
28
- import { getWorkspaceDir } from "../../../../util/platform.js";
29
28
  import { getLogger } from "../logging.js";
30
29
  import {
31
30
  type MemoryV2ConceptRowRecord,
32
31
  recordMemoryV2ActivationLog,
33
32
  } from "../memory-v2-activation-log-store.js";
33
+ import { getWorkspaceDir } from "../paths.js";
34
34
  import {
35
35
  computeOwnActivation,
36
36
  selectCandidates,
@@ -8,8 +8,8 @@
8
8
  // test for the gate does not have to mount the entire lifecycle import graph.
9
9
 
10
10
  import type { AssistantConfig } from "../../../../config/schema.js";
11
- import { getWorkspaceDir } from "../../../../util/platform.js";
12
11
  import { getLogger } from "../logging.js";
12
+ import { getWorkspaceDir } from "../paths.js";
13
13
 
14
14
  const log = getLogger("memory-v2-startup");
15
15
 
@@ -18,8 +18,8 @@
18
18
  * the convention established for the sweep prompt.
19
19
  */
20
20
 
21
- import { getWorkspaceDir } from "../../../../../util/platform.js";
22
21
  import { getLogger } from "../../logging.js";
22
+ import { getWorkspaceDir } from "../../paths.js";
23
23
  import { loadPromptOverride } from "../../prompt-override.js";
24
24
 
25
25
  const log = getLogger("memory-v2-consolidate-prompt");
@@ -27,9 +27,9 @@ import { v5 as uuidv5 } from "uuid";
27
27
 
28
28
  import { getConfig } from "../../../../config/loader.js";
29
29
  import type { SparseEmbedding } from "../../../../persistence/embeddings/embedding-types.js";
30
- import { getDataDir } from "../../../../util/platform.js";
31
30
  import { resolveQdrantUrl } from "../embeddings.js";
32
31
  import { getLogger } from "../logging.js";
32
+ import { getDataDir } from "../paths.js";
33
33
 
34
34
  const log = getLogger("memory-v2-qdrant");
35
35
 
@@ -3,8 +3,8 @@
3
3
  import { createHash } from "node:crypto";
4
4
 
5
5
  import type { AssistantConfig } from "../../../../config/types.js";
6
- import { getWorkspaceDir } from "../../../../util/platform.js";
7
6
  import { getLogger } from "../logging.js";
7
+ import { getWorkspaceDir } from "../paths.js";
8
8
  import { getOrCreateRerankBackend } from "../rerank-local.js";
9
9
  import { readPage } from "./page-store.js";
10
10
 
@@ -19,8 +19,8 @@
19
19
 
20
20
  import type { ChannelId } from "../../../../channels/types.js";
21
21
  import { readPromptFile } from "../../../../prompts/system-prompt.js";
22
- import { getWorkspacePromptPath } from "../../../../util/platform.js";
23
22
  import { getMemoryConfig } from "../config.js";
23
+ import { getWorkspacePromptPath } from "../paths.js";
24
24
 
25
25
  interface MemoryV2StaticBlock {
26
26
  heading: string;
@@ -39,7 +39,6 @@ import {
39
39
  conversations,
40
40
  messages,
41
41
  } from "../../../../persistence/schema/index.js";
42
- import { getWorkspaceDir } from "../../../../util/platform.js";
43
42
  import {
44
43
  appendBufferAndArchive,
45
44
  formatRememberEntry,
@@ -50,6 +49,7 @@ import {
50
49
  userMessage,
51
50
  } from "../llm-helpers.js";
52
51
  import { getLogger } from "../logging.js";
52
+ import { getWorkspaceDir } from "../paths.js";
53
53
  import { renderSweepPrompt } from "./prompts/sweep.js";
54
54
 
55
55
  const log = getLogger("memory-v2-sweep");
@@ -29,7 +29,7 @@ import {
29
29
  isAbortError,
30
30
  isTransientEmbeddingError,
31
31
  } from "../../../../persistence/embeddings/embed.js";
32
- import { abortableSleep, computeRetryDelay } from "../../../../util/retry.js";
32
+ import { abortableSleep, computeRetryDelay } from "../host-utils.js";
33
33
  import { getLogger } from "../logging.js";
34
34
  import { simBatch } from "../v2/sim.js";
35
35
  import { skillSlugFor } from "../v2/skill-store.js";
@@ -73,9 +73,9 @@ import { EmbeddingBackendUnavailableError } from "../../../../persistence/embedd
73
73
  import { EmbeddingBillingBlockError } from "../../../../persistence/embeddings/embedding-billing-breaker.js";
74
74
  import type { MemoryJob } from "../../../../persistence/jobs-store.js";
75
75
  import { executeDeleteManagedSkill } from "../../../../tools/skills/delete-managed.js";
76
- import { getWorkspaceDir } from "../../../../util/platform.js";
77
76
  import { embedWithBackend } from "../embeddings.js";
78
77
  import { getLogger } from "../logging.js";
78
+ import { getWorkspaceDir } from "../paths.js";
79
79
  import { getPageIndex } from "../v2/page-index.js";
80
80
  import { readPage } from "../v2/page-store.js";
81
81
  import { skillSlugFor } from "../v2/skill-store.js";
@@ -1,4 +1,4 @@
1
- import { getWorkspaceDir } from "../../../../util/platform.js";
1
+ import { getWorkspaceDir } from "../paths.js";
2
2
  import { injectedConceptHeader } from "../v2/injected-block-slugs.js";
3
3
  import { readPage, renderPageContent } from "../v2/page-store.js";
4
4
  import { renderCapabilityContent } from "./capabilities.js";