anymous 1.2.3 → 1.2.4
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.
package/package.json
CHANGED
|
@@ -46,6 +46,7 @@ import { Worktree } from "@/worktree"
|
|
|
46
46
|
import { Installation } from "@/installation"
|
|
47
47
|
import { ShareNext } from "@/share/share-next"
|
|
48
48
|
import { SessionShare } from "@/share/session"
|
|
49
|
+
import { Memory } from "@/memory/memory"
|
|
49
50
|
import { Npm } from "@anymous-ai/core/npm"
|
|
50
51
|
import { memoMap } from "@anymous-ai/core/effect/memo-map"
|
|
51
52
|
import { BackgroundJob } from "@/background/job"
|
|
@@ -105,6 +106,7 @@ export const AppLayer = AppNodeBuilderV1.build(
|
|
|
105
106
|
Installation.node,
|
|
106
107
|
ShareNext.node,
|
|
107
108
|
SessionShare.node,
|
|
109
|
+
Memory.node,
|
|
108
110
|
]),
|
|
109
111
|
).pipe(Layer.provideMerge(AppNodeBuilderV1.build(Ripgrep.node)), Layer.provideMerge(Observability.layer))
|
|
110
112
|
|
package/src/memory/memory.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
2
|
-
import { Effect, Layer, Context, Schema
|
|
2
|
+
import { Effect, Layer, Context, Schema } from "effect"
|
|
3
3
|
import { FSUtil } from "@anymous-ai/core/fs-util"
|
|
4
4
|
import { Global } from "@anymous-ai/core/global"
|
|
5
5
|
import path from "path"
|
|
@@ -39,8 +39,8 @@ const loadStore = (fs: FSUtil.Interface, filePath: string) =>
|
|
|
39
39
|
}
|
|
40
40
|
const raw = yield* fs.readFileString(filePath)
|
|
41
41
|
const parsed = JSON.parse(raw) as unknown
|
|
42
|
-
const decoded = yield* Schema.
|
|
43
|
-
Effect.
|
|
42
|
+
const decoded = yield* Effect.sync(() => Schema.decodeUnknownSync(MemoryStore)(parsed)).pipe(
|
|
43
|
+
Effect.catch(() => Effect.succeed({ version: 1, memories: [] } as MemoryStoreType)),
|
|
44
44
|
)
|
|
45
45
|
return decoded
|
|
46
46
|
})
|
|
@@ -58,38 +58,44 @@ const layer = Layer.effect(
|
|
|
58
58
|
const filePath = memoryFilePath(global)
|
|
59
59
|
|
|
60
60
|
const read: Interface["read"] = Effect.fn("Memory.read")(function* (key: string) {
|
|
61
|
-
const store = yield* loadStore(fs, filePath)
|
|
61
|
+
const store = yield* loadStore(fs, filePath).pipe(Effect.orDie)
|
|
62
62
|
return store.memories.find((m) => m.key === key)
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
const write: Interface["write"] = Effect.fn("Memory.write")(function* (
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const write: Interface["write"] = Effect.fn("Memory.write")(function* (
|
|
66
|
+
key: string,
|
|
67
|
+
value: string,
|
|
68
|
+
sessionID?: string,
|
|
69
|
+
) {
|
|
70
|
+
const store = yield* loadStore(fs, filePath).pipe(Effect.orDie)
|
|
71
|
+
const memories = [...store.memories]
|
|
72
|
+
const existing = memories.findIndex((m) => m.key === key)
|
|
68
73
|
const entry: MemoryEntryType = { key, value, timestamp: Date.now(), ...(sessionID ? { sessionID } : {}) }
|
|
69
74
|
if (existing >= 0) {
|
|
70
|
-
|
|
75
|
+
memories[existing] = entry
|
|
71
76
|
} else {
|
|
72
|
-
|
|
77
|
+
memories.push(entry)
|
|
73
78
|
}
|
|
74
|
-
yield* saveStore(fs, filePath, store)
|
|
79
|
+
yield* saveStore(fs, filePath, { ...store, memories }).pipe(Effect.orDie)
|
|
75
80
|
})
|
|
76
81
|
|
|
77
82
|
const list: Interface["list"] = Effect.fn("Memory.list")(function* () {
|
|
78
|
-
const store = yield* loadStore(fs, filePath)
|
|
79
|
-
return store.memories
|
|
83
|
+
const store = yield* loadStore(fs, filePath).pipe(Effect.orDie)
|
|
84
|
+
return [...store.memories]
|
|
80
85
|
})
|
|
81
86
|
|
|
82
87
|
const remove: Interface["delete"] = Effect.fn("Memory.delete")(function* (key: string) {
|
|
83
|
-
const store = yield* loadStore(fs, filePath)
|
|
84
|
-
const
|
|
88
|
+
const store = yield* loadStore(fs, filePath).pipe(Effect.orDie)
|
|
89
|
+
const memories = [...store.memories]
|
|
90
|
+
const idx = memories.findIndex((m) => m.key === key)
|
|
85
91
|
if (idx < 0) return false
|
|
86
|
-
|
|
87
|
-
yield* saveStore(fs, filePath, store)
|
|
92
|
+
memories.splice(idx, 1)
|
|
93
|
+
yield* saveStore(fs, filePath, { ...store, memories }).pipe(Effect.orDie)
|
|
88
94
|
return true
|
|
89
95
|
})
|
|
90
96
|
|
|
91
97
|
const allText: Interface["allText"] = Effect.fn("Memory.allText")(function* () {
|
|
92
|
-
const store = yield* loadStore(fs, filePath)
|
|
98
|
+
const store = yield* loadStore(fs, filePath).pipe(Effect.orDie)
|
|
93
99
|
if (store.memories.length === 0) return undefined
|
|
94
100
|
const lines = store.memories.map((m) => `- ${m.key}: ${m.value}`)
|
|
95
101
|
return `## Shared Context / Memory\n\n${lines.join("\n")}`
|
|
@@ -18,6 +18,7 @@ import { Git } from "@/git"
|
|
|
18
18
|
import { Installation } from "@/installation"
|
|
19
19
|
import { LSP } from "@/lsp/lsp"
|
|
20
20
|
import { MCP } from "@/mcp"
|
|
21
|
+
import { Memory } from "@/memory/memory"
|
|
21
22
|
import { McpAuth } from "@/mcp/auth"
|
|
22
23
|
import { Permission } from "@/permission"
|
|
23
24
|
import { Plugin } from "@/plugin"
|
|
@@ -260,6 +261,7 @@ const app = LayerNode.group([
|
|
|
260
261
|
Installation.node,
|
|
261
262
|
ShareNext.node,
|
|
262
263
|
SessionShare.node,
|
|
264
|
+
Memory.node,
|
|
263
265
|
InstanceStore.node,
|
|
264
266
|
httpClient,
|
|
265
267
|
EventV2.node,
|
package/src/tool/memory.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Memory } from "@/memory/memory"
|
|
|
4
4
|
import DESCRIPTION from "./memory.txt"
|
|
5
5
|
|
|
6
6
|
export const Parameters = Schema.Struct({
|
|
7
|
-
action: Schema.
|
|
7
|
+
action: Schema.Literals(["read", "write", "delete", "list"]).annotate({ description: "Action to perform" }),
|
|
8
8
|
key: Schema.optional(Schema.String).annotate({ description: "Memory key (required for read/write/delete)" }),
|
|
9
9
|
value: Schema.optional(Schema.String).annotate({ description: "Memory value (required for write)" }),
|
|
10
10
|
})
|
package/src/tool/registry.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Ripgrep } from "@anymous-ai/core/ripgrep"
|
|
|
4
4
|
import { PlanExitTool } from "./plan"
|
|
5
5
|
import { ComputerTool } from "./computer"
|
|
6
6
|
import { MemoryTool } from "./memory"
|
|
7
|
+
import { Memory } from "@/memory/memory"
|
|
7
8
|
import { Session } from "@/session/session"
|
|
8
9
|
import { QuestionTool } from "./question"
|
|
9
10
|
import { ShellTool } from "./shell"
|
|
@@ -450,6 +451,7 @@ export const node = LayerNode.make({
|
|
|
450
451
|
Truncate.node,
|
|
451
452
|
RuntimeFlags.node,
|
|
452
453
|
MCP.node,
|
|
454
|
+
Memory.node,
|
|
453
455
|
Database.node,
|
|
454
456
|
Ripgrep.node,
|
|
455
457
|
],
|