@nguyenthdat/opencode-memory 0.2.0

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/THIRD_PARTY_NOTICES.md +14 -0
  4. package/dist/contracts.d.ts +96 -0
  5. package/dist/contracts.d.ts.map +1 -0
  6. package/dist/contracts.js +46 -0
  7. package/dist/contracts.js.map +1 -0
  8. package/dist/generated/memory_pb.d.ts +227 -0
  9. package/dist/generated/memory_pb.d.ts.map +1 -0
  10. package/dist/generated/memory_pb.js +112 -0
  11. package/dist/generated/memory_pb.js.map +1 -0
  12. package/dist/index.d.ts +15 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +24 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/plugin.d.ts +7 -0
  17. package/dist/plugin.d.ts.map +1 -0
  18. package/dist/plugin.js +665 -0
  19. package/dist/plugin.js.map +1 -0
  20. package/dist/policy.d.ts +19 -0
  21. package/dist/policy.d.ts.map +1 -0
  22. package/dist/policy.js +125 -0
  23. package/dist/policy.js.map +1 -0
  24. package/dist/protocol.d.ts +31 -0
  25. package/dist/protocol.d.ts.map +1 -0
  26. package/dist/protocol.js +220 -0
  27. package/dist/protocol.js.map +1 -0
  28. package/dist/session-context.d.ts +40 -0
  29. package/dist/session-context.d.ts.map +1 -0
  30. package/dist/session-context.js +92 -0
  31. package/dist/session-context.js.map +1 -0
  32. package/dist/shared-markdown.d.ts +11 -0
  33. package/dist/shared-markdown.d.ts.map +1 -0
  34. package/dist/shared-markdown.js +178 -0
  35. package/dist/shared-markdown.js.map +1 -0
  36. package/dist/sidecar-client.d.ts +39 -0
  37. package/dist/sidecar-client.d.ts.map +1 -0
  38. package/dist/sidecar-client.js +397 -0
  39. package/dist/sidecar-client.js.map +1 -0
  40. package/dist/validation.d.ts +2 -0
  41. package/dist/validation.d.ts.map +1 -0
  42. package/dist/validation.js +29 -0
  43. package/dist/validation.js.map +1 -0
  44. package/notices/ZVEC_NOTICE +95 -0
  45. package/package.json +90 -0
  46. package/rules/flow.md +16 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dat Nguyen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # OpenCode Native Memory
2
+
3
+ Local-first persistent memory for OpenCode. The plugin runs a native Rust sidecar, stores project-scoped memories in zvec, and embeds text locally with llama.cpp. No memory content or embedding request is sent to a hosted inference service.
4
+
5
+ ## Highlights
6
+
7
+ - Hybrid dense, lexical, metadata, and feedback-aware retrieval
8
+ - Local GGUF embeddings through `utilityai/llama-cpp-rs`
9
+ - Default pinned `Qwen3-Embedding-4B` model from Hugging Face
10
+ - Session-family, agent, project, and repository scopes
11
+ - Durable taxonomy, confidence, supersession, conflict, pin, lock, expiry, and tombstone metadata
12
+ - Markdown-backed shared repository memory under `.opencode/memory/`
13
+ - Length-delimited Protobuf protocol between TypeScript and Rust
14
+ - Native sidecar packages for macOS, Linux, and Windows
15
+
16
+ ## Install
17
+
18
+ Add the plugin to `opencode.json` or `opencode.jsonc`:
19
+
20
+ ```json
21
+ {
22
+ "plugin": ["@nguyenthdat/opencode-memory@0.2.0"]
23
+ }
24
+ ```
25
+
26
+ npm installs one matching optional native package for the current platform. Reinstall without `--omit=optional`; the plugin intentionally has no postinstall script or runtime binary download.
27
+
28
+ Supported packages:
29
+
30
+ | OS | Architecture | Native package |
31
+ | ----------- | ------------ | ---------------------------------------------- |
32
+ | macOS | ARM64 | `@nguyenthdat/opencode-memory-darwin-arm64` |
33
+ | macOS | x64 | `@nguyenthdat/opencode-memory-darwin-x64` |
34
+ | Linux glibc | ARM64 | `@nguyenthdat/opencode-memory-linux-arm64-gnu` |
35
+ | Linux glibc | x64 | `@nguyenthdat/opencode-memory-linux-x64-gnu` |
36
+ | Windows | x64 MSVC | `@nguyenthdat/opencode-memory-win32-x64-msvc` |
37
+
38
+ The first memory operation downloads the default GGUF model into the local model cache. Override `OPENCODE_MEMORY_EMBEDDING_MODEL_PATH` to use an existing local model and avoid a network download.
39
+
40
+ Add `rules/flow.md` to the project instructions if memory tool usage should be explicit for every agent.
41
+
42
+ ## Memory Tools
43
+
44
+ | Tool | Purpose |
45
+ | ----------------- | ---------------------------------------------------- |
46
+ | `memory_search` | Retrieve relevant memories within a context budget |
47
+ | `memory_store` | Store a verified durable memory |
48
+ | `memory_get` | Fetch complete records by ID |
49
+ | `memory_list` | Review/filter lifecycle-indexed memories |
50
+ | `memory_update` | Correct semantic content or lifecycle metadata |
51
+ | `memory_pin` | Pin or unpin without re-embedding |
52
+ | `memory_lock` | Lock or unlock without re-embedding |
53
+ | `memory_delete` | Delete records, with tombstones by default |
54
+ | `memory_promote` | Promote reviewed local memory to repository Markdown |
55
+ | `memory_feedback` | Record whether recalled memories were useful |
56
+ | `memory_optimize` | Prune expired records and optimize indexes |
57
+ | `memory_status` | Inspect backend, model, and schema status |
58
+ | `memory_doctor` | Run shallow or deep integrity checks |
59
+ | `memory_purge` | Confirm and delete the complete project store |
60
+
61
+ The 15 stable taxonomy values are `task_attempt`, `tool_call`, `session_summary`, `architecture_fact`, `codebase_fact`, `user_fact`, `fix_pattern`, `code_template`, `tool_heuristic`, `code_style`, `library_pref`, `workflow_pref`, `decision`, `team_convention`, and `project_standard`.
62
+
63
+ ## Embedding Models
64
+
65
+ The default is:
66
+
67
+ - Repository: `Qwen/Qwen3-Embedding-4B-GGUF`
68
+ - File: `Qwen3-Embedding-4B-Q4_K_M.gguf`
69
+ - Revision: `f4602530db1d980e16da9d7d3a70294cf5c190be`
70
+ - Native dimension: 2560
71
+ - Pooling: last token
72
+ - Normalization: L2
73
+
74
+ "Any Hugging Face model" means any **GGUF embedding model compatible with the bundled llama.cpp revision**. Safetensors-only repositories are not loaded directly. Model templates and pooling must match the chosen model.
75
+
76
+ Changing model identity or embedding dimension requires rebuilding the project's vector index. The sidecar rejects a mismatched existing collection instead of silently mixing incompatible vectors.
77
+
78
+ ### Environment
79
+
80
+ | Variable | Default / purpose |
81
+ | -------------------------------------------- | ---------------------------------------------------------------------------- |
82
+ | `OPENCODE_MEMORY_EMBEDDING_MODEL_PATH` | Local GGUF path; bypasses Hugging Face |
83
+ | `OPENCODE_MEMORY_EMBEDDING_MODEL_REPO` | `Qwen/Qwen3-Embedding-4B-GGUF` |
84
+ | `OPENCODE_MEMORY_EMBEDDING_MODEL_FILE` | `Qwen3-Embedding-4B-Q4_K_M.gguf` |
85
+ | `OPENCODE_MEMORY_EMBEDDING_MODEL_REVISION` | Pinned Hugging Face commit |
86
+ | `OPENCODE_MEMORY_EMBEDDING_POOLING` | `last`; accepts `unspecified`, `mean`, `cls`, `last` |
87
+ | `OPENCODE_MEMORY_EMBEDDING_ATTENTION` | `causal`; accepts `unspecified`, `causal`, `non_causal` |
88
+ | `OPENCODE_MEMORY_EMBEDDING_QUERY_TEMPLATE` | Query instruction containing `{text}` |
89
+ | `OPENCODE_MEMORY_EMBEDDING_PASSAGE_TEMPLATE` | `{text}` |
90
+ | `OPENCODE_MEMORY_EMBEDDING_ADD_BOS` | `true` |
91
+ | `OPENCODE_MEMORY_EMBEDDING_APPEND_EOS` | `true` |
92
+ | `OPENCODE_MEMORY_EMBEDDING_NORMALIZE` | `true` |
93
+ | `OPENCODE_MEMORY_EMBEDDING_DIMENSION` | Native model dimension; lower values use MRL truncation then renormalization |
94
+ | `OPENCODE_MEMORY_EMBEDDING_CONTEXT_SIZE` | `8192` |
95
+ | `OPENCODE_MEMORY_EMBEDDING_THREADS` | Available parallelism |
96
+ | `OPENCODE_MEMORY_EMBEDDING_GPU_LAYERS` | All layers when GPU offload is supported, otherwise `0` |
97
+ | `OPENCODE_MEMORY_PROJECT_ROOT` | Override project discovery root |
98
+ | `OPENCODE_MEMORY_DATA_DIR` | Override project store base directory |
99
+ | `OPENCODE_MEMORY_MODEL_CACHE` | Override local Hugging Face model cache |
100
+ | `OPENCODE_NATIVE_MEMORY_BIN` | Development/debug sidecar override |
101
+
102
+ Example local model:
103
+
104
+ ```sh
105
+ export OPENCODE_MEMORY_EMBEDDING_MODEL_PATH="$HOME/models/nomic-embed-text-v1.5.Q5_K_M.gguf"
106
+ export OPENCODE_MEMORY_EMBEDDING_POOLING="mean"
107
+ export OPENCODE_MEMORY_EMBEDDING_QUERY_TEMPLATE="search_query: {text}"
108
+ export OPENCODE_MEMORY_EMBEDDING_PASSAGE_TEMPLATE="search_document: {text}"
109
+ ```
110
+
111
+ ## Storage and Sharing
112
+
113
+ Private state uses the platform data directory under `opencode/memory/<project-id>/`. Models use the platform cache directory under `opencode/memory/models/`.
114
+
115
+ Repository memory is canonical Markdown in:
116
+
117
+ ```text
118
+ .opencode/memory/
119
+ architecture.md
120
+ conventions.md
121
+ gotchas.md
122
+ decisions/
123
+ ```
124
+
125
+ Shared Markdown is treated as untrusted data: paths are contained under `.opencode/memory`, YAML is parsed with a strict schema, instruction-shaped content and likely secrets are rejected, and imported records cannot be pinned or locked through RPC.
126
+
127
+ ## Architecture
128
+
129
+ ```text
130
+ OpenCode plugin (TypeScript)
131
+ -> length-delimited Protobuf over stdin/stdout
132
+ Rust sidecar
133
+ -> lifecycle/taxonomy policy
134
+ -> llama.cpp GGUF embedder
135
+ -> zvec vector + FTS collection
136
+ -> atomic JSON lifecycle state
137
+ ```
138
+
139
+ The Protobuf schema is `schema/memory.proto`. Rust bindings are generated at Cargo build time with `prost-build`; TypeScript bindings are committed at `opencode-memory/src/generated/memory_pb.ts` and reproduced with `bun run generate:protocol`.
140
+
141
+ ## Development
142
+
143
+ Requirements: Bun 1.3+, Rust 1.88+, and `protoc`.
144
+
145
+ ```sh
146
+ bun install
147
+ bun run generate:protocol:check
148
+ bun run typecheck
149
+ bun run test:ts
150
+ cargo test --locked --lib
151
+ cargo clippy --all-targets --locked -- -D warnings
152
+ bun run build
153
+ bun run pack:check
154
+ ```
155
+
156
+ Build the local sidecar:
157
+
158
+ ```sh
159
+ bun run build:native:release
160
+ ```
161
+
162
+ GPU features are opt-in Cargo features: `metal`, `cuda`, `cuda-no-vmm`, `vulkan`, `openmp`, and `static-openmp`.
163
+
164
+ ## Releases
165
+
166
+ Tags matching `vX.Y.Z` build and package the five native targets, publish native packages first, publish the umbrella plugin with npm provenance, and create a GitHub release containing all tarballs and a checksum for the umbrella package. `package.json`, `Cargo.toml`, and every native package must carry the same version.
167
+
168
+ ## License
169
+
170
+ MIT. Bundled dependency notices are in `THIRD_PARTY_NOTICES.md` and `notices/`.
@@ -0,0 +1,14 @@
1
+ # Third-Party Notices
2
+
3
+ The native memory binary and TypeScript plugin include or link dependencies
4
+ under permissive licenses, including:
5
+
6
+ - Alibaba `zvec` and `zvec-rust` (Apache-2.0)
7
+ - UtilityAI `llama-cpp-rs` (MIT OR Apache-2.0)
8
+ - `llama.cpp` (MIT)
9
+ - Hugging Face `hf-hub` (Apache-2.0)
10
+ - Tokio `prost` (Apache-2.0)
11
+ - Buf Protobuf-ES (Apache-2.0 AND BSD-3-Clause)
12
+
13
+ The upstream zvec notice, including notices for bundled Unicode data and
14
+ pyglass-derived code, is redistributed at `notices/ZVEC_NOTICE`.
@@ -0,0 +1,96 @@
1
+ export declare const MEMORY_KINDS: readonly ["decision", "preference", "fact", "pattern", "gotcha", "summary"];
2
+ export declare const MEMORY_SCOPES: readonly ["session", "agent", "project", "repository"];
3
+ export declare const MEMORY_TAXONOMIES: readonly ["task_attempt", "tool_call", "session_summary", "architecture_fact", "codebase_fact", "user_fact", "fix_pattern", "code_template", "tool_heuristic", "code_style", "library_pref", "workflow_pref", "decision", "team_convention", "project_standard"];
4
+ export declare const WRITABLE_MEMORY_SCOPES: readonly ["session", "agent", "project"];
5
+ export declare const FEEDBACK_EVENTS: readonly ["used", "ignored", "error"];
6
+ export declare const LOCK_ACTIONS: readonly ["lock", "unlock"];
7
+ export declare const LOCK_REASON_MAX = 240;
8
+ export declare const UNLOCK_FORBIDDEN_FIELDS: readonly ["content", "title", "kind", "importance", "tags", "scope", "expires_in_days", "clear_expiry", "code_paths", "pinned", "taxonomy", "confidence", "conflict_with"];
9
+ export interface MemoryRecord {
10
+ id: string;
11
+ title: string;
12
+ content: string;
13
+ kind: (typeof MEMORY_KINDS)[number];
14
+ importance: number;
15
+ tags: string[];
16
+ source: string;
17
+ created_at_ms: number;
18
+ updated_at_ms: number;
19
+ scope: (typeof MEMORY_SCOPES)[number];
20
+ origin: "manual" | "auto_compaction" | "shared_markdown" | "legacy";
21
+ expires_at_ms?: number | null;
22
+ stale: boolean;
23
+ code_anchors: Array<{
24
+ path: string;
25
+ sha256: string;
26
+ git_sha?: string;
27
+ }>;
28
+ feedback: {
29
+ injected: number;
30
+ used: number;
31
+ ignored: number;
32
+ error: number;
33
+ };
34
+ score?: number;
35
+ pinned: boolean;
36
+ locked: boolean;
37
+ lock_reason?: string | null;
38
+ taxonomy: (typeof MEMORY_TAXONOMIES)[number];
39
+ confidence: number;
40
+ superseded_by?: string | null;
41
+ supersedes?: string[];
42
+ conflict_with?: string[];
43
+ }
44
+ export interface SearchResponse {
45
+ query: string;
46
+ retrieval_id?: string | null;
47
+ count: number;
48
+ candidates_considered: number;
49
+ budget_chars: number;
50
+ used_chars: number;
51
+ abstained: boolean;
52
+ abstention_reason?: string | null;
53
+ score_version: string;
54
+ memories: MemoryRecord[];
55
+ }
56
+ export interface ListResponse {
57
+ total: number;
58
+ offset: number;
59
+ count: number;
60
+ memories: MemoryRecord[];
61
+ }
62
+ export interface PendingRecall {
63
+ retrievalID: string;
64
+ memoryIDs: string[];
65
+ }
66
+ export interface CuratedCandidate {
67
+ title: string;
68
+ content: string;
69
+ kind: Exclude<(typeof MEMORY_KINDS)[number], "summary">;
70
+ importance: number;
71
+ tags: string[];
72
+ code_paths: string[];
73
+ }
74
+ export interface SharedMemoryRecord extends CuratedCandidate {
75
+ source: string;
76
+ }
77
+ export interface SharedSyncResponse {
78
+ imported: number;
79
+ removed: number;
80
+ rejected: number;
81
+ rejected_sources: string[];
82
+ }
83
+ export interface RpcResponse {
84
+ id: number;
85
+ ok: boolean;
86
+ result?: unknown | undefined;
87
+ error?: string | undefined;
88
+ }
89
+ export interface PendingRequest {
90
+ resolve(value: unknown): void;
91
+ reject(error: Error): void;
92
+ timer: ReturnType<typeof setTimeout>;
93
+ abort?: (() => void) | undefined;
94
+ signal?: AbortSignal | undefined;
95
+ }
96
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../opencode-memory/src/contracts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,6EAOf,CAAC;AAEX,eAAO,MAAM,aAAa,wDAAyD,CAAC;AAEpF,eAAO,MAAM,iBAAiB,kQAgBpB,CAAC;AAEX,eAAO,MAAM,sBAAsB,0CAA2C,CAAC;AAE/E,eAAO,MAAM,eAAe,uCAAwC,CAAC;AAErE,eAAO,MAAM,YAAY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M,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC"}
@@ -0,0 +1,46 @@
1
+ export const MEMORY_KINDS = [
2
+ "decision",
3
+ "preference",
4
+ "fact",
5
+ "pattern",
6
+ "gotcha",
7
+ "summary",
8
+ ];
9
+ export const MEMORY_SCOPES = ["session", "agent", "project", "repository"];
10
+ export const MEMORY_TAXONOMIES = [
11
+ "task_attempt",
12
+ "tool_call",
13
+ "session_summary",
14
+ "architecture_fact",
15
+ "codebase_fact",
16
+ "user_fact",
17
+ "fix_pattern",
18
+ "code_template",
19
+ "tool_heuristic",
20
+ "code_style",
21
+ "library_pref",
22
+ "workflow_pref",
23
+ "decision",
24
+ "team_convention",
25
+ "project_standard",
26
+ ];
27
+ export const WRITABLE_MEMORY_SCOPES = ["session", "agent", "project"];
28
+ export const FEEDBACK_EVENTS = ["used", "ignored", "error"];
29
+ export const LOCK_ACTIONS = ["lock", "unlock"];
30
+ export const LOCK_REASON_MAX = 240;
31
+ export const UNLOCK_FORBIDDEN_FIELDS = [
32
+ "content",
33
+ "title",
34
+ "kind",
35
+ "importance",
36
+ "tags",
37
+ "scope",
38
+ "expires_in_days",
39
+ "clear_expiry",
40
+ "code_paths",
41
+ "pinned",
42
+ "taxonomy",
43
+ "confidence",
44
+ "conflict_with",
45
+ ];
46
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../opencode-memory/src/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU;IACV,YAAY;IACZ,MAAM;IACN,SAAS;IACT,QAAQ;IACR,SAAS;CACD,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,CAAU,CAAC;AAEpF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,mBAAmB;IACnB,eAAe;IACf,WAAW;IACX,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,eAAe;IACf,UAAU;IACV,iBAAiB;IACjB,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,SAAS;IACT,OAAO;IACP,MAAM;IACN,YAAY;IACZ,MAAM;IACN,OAAO;IACP,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,eAAe;CACP,CAAC"}
@@ -0,0 +1,227 @@
1
+ import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
2
+ import type { Message } from "@bufbuild/protobuf";
3
+ /**
4
+ * Describes the file memory.proto.
5
+ */
6
+ export declare const file_memory: GenFile;
7
+ /**
8
+ * @generated from message opencode.memory.v1.ValueList
9
+ */
10
+ export type ValueList = Message<"opencode.memory.v1.ValueList"> & {
11
+ /**
12
+ * @generated from field: repeated opencode.memory.v1.Value values = 1;
13
+ */
14
+ values: Value[];
15
+ };
16
+ /**
17
+ * Describes the message opencode.memory.v1.ValueList.
18
+ * Use `create(ValueListSchema)` to create a new message.
19
+ */
20
+ export declare const ValueListSchema: GenMessage<ValueList>;
21
+ /**
22
+ * @generated from message opencode.memory.v1.ValueObject
23
+ */
24
+ export type ValueObject = Message<"opencode.memory.v1.ValueObject"> & {
25
+ /**
26
+ * @generated from field: map<string, opencode.memory.v1.Value> fields = 1;
27
+ */
28
+ fields: {
29
+ [key: string]: Value;
30
+ };
31
+ };
32
+ /**
33
+ * Describes the message opencode.memory.v1.ValueObject.
34
+ * Use `create(ValueObjectSchema)` to create a new message.
35
+ */
36
+ export declare const ValueObjectSchema: GenMessage<ValueObject>;
37
+ /**
38
+ * @generated from message opencode.memory.v1.Value
39
+ */
40
+ export type Value = Message<"opencode.memory.v1.Value"> & {
41
+ /**
42
+ * @generated from oneof opencode.memory.v1.Value.kind
43
+ */
44
+ kind: {
45
+ /**
46
+ * @generated from field: bool boolean_value = 1;
47
+ */
48
+ value: boolean;
49
+ case: "booleanValue";
50
+ } | {
51
+ /**
52
+ * @generated from field: sint64 signed_value = 2;
53
+ */
54
+ value: bigint;
55
+ case: "signedValue";
56
+ } | {
57
+ /**
58
+ * @generated from field: uint64 unsigned_value = 3;
59
+ */
60
+ value: bigint;
61
+ case: "unsignedValue";
62
+ } | {
63
+ /**
64
+ * @generated from field: double float_value = 4;
65
+ */
66
+ value: number;
67
+ case: "floatValue";
68
+ } | {
69
+ /**
70
+ * @generated from field: string text_value = 5;
71
+ */
72
+ value: string;
73
+ case: "textValue";
74
+ } | {
75
+ /**
76
+ * @generated from field: opencode.memory.v1.ValueList list_value = 6;
77
+ */
78
+ value: ValueList;
79
+ case: "listValue";
80
+ } | {
81
+ /**
82
+ * @generated from field: opencode.memory.v1.ValueObject object_value = 7;
83
+ */
84
+ value: ValueObject;
85
+ case: "objectValue";
86
+ } | {
87
+ /**
88
+ * @generated from field: bool null_value = 8;
89
+ */
90
+ value: boolean;
91
+ case: "nullValue";
92
+ } | {
93
+ case: undefined;
94
+ value?: undefined;
95
+ };
96
+ };
97
+ /**
98
+ * Describes the message opencode.memory.v1.Value.
99
+ * Use `create(ValueSchema)` to create a new message.
100
+ */
101
+ export declare const ValueSchema: GenMessage<Value>;
102
+ /**
103
+ * @generated from message opencode.memory.v1.Request
104
+ */
105
+ export type Request = Message<"opencode.memory.v1.Request"> & {
106
+ /**
107
+ * @generated from field: uint64 id = 1;
108
+ */
109
+ id: bigint;
110
+ /**
111
+ * @generated from field: opencode.memory.v1.Method method = 2;
112
+ */
113
+ method: Method;
114
+ /**
115
+ * @generated from field: opencode.memory.v1.Value params = 3;
116
+ */
117
+ params?: Value | undefined;
118
+ };
119
+ /**
120
+ * Describes the message opencode.memory.v1.Request.
121
+ * Use `create(RequestSchema)` to create a new message.
122
+ */
123
+ export declare const RequestSchema: GenMessage<Request>;
124
+ /**
125
+ * @generated from message opencode.memory.v1.Response
126
+ */
127
+ export type Response = Message<"opencode.memory.v1.Response"> & {
128
+ /**
129
+ * @generated from field: uint64 id = 1;
130
+ */
131
+ id: bigint;
132
+ /**
133
+ * @generated from field: bool ok = 2;
134
+ */
135
+ ok: boolean;
136
+ /**
137
+ * @generated from field: opencode.memory.v1.Value result = 3;
138
+ */
139
+ result?: Value | undefined;
140
+ /**
141
+ * @generated from field: string error = 4;
142
+ */
143
+ error: string;
144
+ };
145
+ /**
146
+ * Describes the message opencode.memory.v1.Response.
147
+ * Use `create(ResponseSchema)` to create a new message.
148
+ */
149
+ export declare const ResponseSchema: GenMessage<Response>;
150
+ /**
151
+ * @generated from enum opencode.memory.v1.Method
152
+ */
153
+ export declare enum Method {
154
+ /**
155
+ * @generated from enum value: METHOD_UNSPECIFIED = 0;
156
+ */
157
+ UNSPECIFIED = 0,
158
+ /**
159
+ * @generated from enum value: METHOD_SEARCH = 1;
160
+ */
161
+ SEARCH = 1,
162
+ /**
163
+ * @generated from enum value: METHOD_STORE = 2;
164
+ */
165
+ STORE = 2,
166
+ /**
167
+ * @generated from enum value: METHOD_GET = 3;
168
+ */
169
+ GET = 3,
170
+ /**
171
+ * @generated from enum value: METHOD_LIST = 4;
172
+ */
173
+ LIST = 4,
174
+ /**
175
+ * @generated from enum value: METHOD_UPDATE = 5;
176
+ */
177
+ UPDATE = 5,
178
+ /**
179
+ * @generated from enum value: METHOD_PIN = 6;
180
+ */
181
+ PIN = 6,
182
+ /**
183
+ * @generated from enum value: METHOD_LOCK = 7;
184
+ */
185
+ LOCK = 7,
186
+ /**
187
+ * @generated from enum value: METHOD_DELETE = 8;
188
+ */
189
+ DELETE = 8,
190
+ /**
191
+ * @generated from enum value: METHOD_FORGET = 9;
192
+ */
193
+ FORGET = 9,
194
+ /**
195
+ * @generated from enum value: METHOD_PURGE = 10;
196
+ */
197
+ PURGE = 10,
198
+ /**
199
+ * @generated from enum value: METHOD_FEEDBACK = 11;
200
+ */
201
+ FEEDBACK = 11,
202
+ /**
203
+ * @generated from enum value: METHOD_SYNC_SHARED = 12;
204
+ */
205
+ SYNC_SHARED = 12,
206
+ /**
207
+ * @generated from enum value: METHOD_STATUS = 13;
208
+ */
209
+ STATUS = 13,
210
+ /**
211
+ * @generated from enum value: METHOD_OPTIMIZE = 14;
212
+ */
213
+ OPTIMIZE = 14,
214
+ /**
215
+ * @generated from enum value: METHOD_DOCTOR = 15;
216
+ */
217
+ DOCTOR = 15,
218
+ /**
219
+ * @generated from enum value: METHOD_SHUTDOWN = 16;
220
+ */
221
+ SHUTDOWN = 16
222
+ }
223
+ /**
224
+ * Describes the enum opencode.memory.v1.Method.
225
+ */
226
+ export declare const MethodSchema: GenEnum<Method>;
227
+ //# sourceMappingURL=memory_pb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory_pb.d.ts","sourceRoot":"","sources":["../../opencode-memory/src/generated/memory_pb.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAEjF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAC23C,CAAC;AAEt5C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,8BAA8B,CAAC,GAAG;IAChE;;OAEG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC,SAAS,CACrB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,gCAAgC,CAAC,GAAG;IACpE;;OAEG;IACH,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,WAAW,CACzB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,0BAA0B,CAAC,GAAG;IACxD;;OAEG;IACH,IAAI,EAAE;QACJ;;WAEG;QACH,KAAK,EAAE,OAAO,CAAC;QACf,IAAI,EAAE,cAAc,CAAC;KACtB,GAAG;QACF;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,aAAa,CAAC;KACrB,GAAG;QACF;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,eAAe,CAAC;KACvB,GAAG;QACF;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,YAAY,CAAC;KACpB,GAAG;QACF;;WAEG;QACH,KAAK,EAAE,MAAM,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