@chenhw7/dsh-memory 0.1.0 → 0.1.2
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/README.md +95 -37
- package/README.zh-CN.md +96 -35
- package/cordis.patch.yml +10 -0
- package/lib/brand.d.ts +7 -0
- package/lib/brand.d.ts.map +1 -1
- package/lib/brand.js +7 -0
- package/lib/brand.js.map +1 -1
- package/lib/client/index.js +826 -0
- package/lib/context/conflict.d.ts +59 -0
- package/lib/context/conflict.d.ts.map +1 -0
- package/lib/context/conflict.js +75 -0
- package/lib/context/conflict.js.map +1 -0
- package/lib/context/index.d.ts +11 -2
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +36 -9
- package/lib/context/index.js.map +1 -1
- package/lib/context/policy.d.ts +23 -2
- package/lib/context/policy.d.ts.map +1 -1
- package/lib/context/policy.js +77 -1
- package/lib/context/policy.js.map +1 -1
- package/lib/index.d.ts +50 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +22 -3
- package/lib/index.js.map +1 -1
- package/lib/invariant.d.ts.map +1 -1
- package/lib/remote/index.d.ts +146 -0
- package/lib/remote/index.d.ts.map +1 -0
- package/lib/remote/index.js +257 -0
- package/lib/remote/index.js.map +1 -0
- package/lib/remote/typert.remote-client.d.ts +75 -0
- package/lib/remote/typert.remote-client.js +86 -0
- package/lib/remote/types.d.ts +9 -0
- package/lib/remote/types.d.ts.map +1 -0
- package/lib/remote/types.js +9 -0
- package/lib/remote/types.js.map +1 -0
- package/lib/review/accumulator.d.ts +18 -5
- package/lib/review/accumulator.d.ts.map +1 -1
- package/lib/review/accumulator.js +52 -14
- package/lib/review/accumulator.js.map +1 -1
- package/lib/review/dedup.d.ts +79 -0
- package/lib/review/dedup.d.ts.map +1 -0
- package/lib/review/dedup.js +171 -0
- package/lib/review/dedup.js.map +1 -0
- package/lib/review/extract.d.ts +28 -8
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +161 -23
- package/lib/review/extract.js.map +1 -1
- package/lib/review/index.d.ts +10 -0
- package/lib/review/index.d.ts.map +1 -1
- package/lib/review/index.js +55 -11
- package/lib/review/index.js.map +1 -1
- package/lib/scanner.d.ts +16 -0
- package/lib/scanner.d.ts.map +1 -1
- package/lib/scanner.js +25 -2
- package/lib/scanner.js.map +1 -1
- package/lib/store/index.d.ts +49 -0
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +238 -15
- package/lib/store/index.js.map +1 -1
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +173 -3
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +60 -4
- package/lib/types.d.ts.map +1 -1
- package/package.json +39 -17
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@Remote` service wrapping the `MemoryStore` for the memory management UI (§3.8).
|
|
3
|
+
*
|
|
4
|
+
* This service exposes the store's CRUD operations as `@Remote` methods callable from
|
|
5
|
+
* the client-side UI via `ctx.remote.memory.*`. Writes stay scanner-gated and
|
|
6
|
+
* write-serialized through the existing store contract. The service delegates to
|
|
7
|
+
* `ctx.memory` — it does not duplicate the store.
|
|
8
|
+
*
|
|
9
|
+
* Host integration: the `./remote` subpath must be mounted in `dsh-api-remotes`
|
|
10
|
+
* (see TODO §3.8 verification notes). Write methods should be pinned to loopback
|
|
11
|
+
* via `PRIVILEGED_METHODS`.
|
|
12
|
+
*
|
|
13
|
+
* @module @chenhw7/dsh-memory/remote
|
|
14
|
+
*/
|
|
15
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
16
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
17
|
+
import type { AuditEntry } from '../types.ts';
|
|
18
|
+
/** Cordis plugin name. */
|
|
19
|
+
export declare const name = "memory-remote";
|
|
20
|
+
/** The memory service is required. */
|
|
21
|
+
export declare const inject: string[];
|
|
22
|
+
declare module '@deepseek-ai/cordis' {
|
|
23
|
+
interface Context {
|
|
24
|
+
memoryRemote: MemoryRemoteService;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Cordis function-plugin apply: instantiate the MemoryRemoteService. The
|
|
29
|
+
* TypertRemoteService constructor calls super(ctx, 'memoryRemote') which
|
|
30
|
+
* registers the service on ctx.memoryRemote via Cordis Service.provide.
|
|
31
|
+
* Called by the cordis.patch.yml fifth row.
|
|
32
|
+
*/
|
|
33
|
+
export declare function apply(ctx: Context): void;
|
|
34
|
+
/** Wire-safe entry projection (branded id as plain string). */
|
|
35
|
+
export interface MemoryEntryJson {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly scope: 'global' | 'project' | 'user';
|
|
38
|
+
readonly category?: string;
|
|
39
|
+
readonly content: string;
|
|
40
|
+
readonly projectName?: string;
|
|
41
|
+
readonly createdAt: number;
|
|
42
|
+
readonly updatedAt: number;
|
|
43
|
+
readonly pinned?: boolean;
|
|
44
|
+
readonly lastRecalledAt?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MemoryListRequest {
|
|
47
|
+
readonly scope?: 'global' | 'project' | 'user';
|
|
48
|
+
readonly projectName?: string;
|
|
49
|
+
readonly limit?: number;
|
|
50
|
+
readonly offset?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface MemoryListResult {
|
|
53
|
+
readonly entries: readonly MemoryEntryJson[];
|
|
54
|
+
readonly total: number;
|
|
55
|
+
}
|
|
56
|
+
export interface MemorySearchRequest {
|
|
57
|
+
readonly scope?: 'global' | 'project' | 'user';
|
|
58
|
+
readonly category?: string;
|
|
59
|
+
readonly projectName?: string;
|
|
60
|
+
readonly query?: string;
|
|
61
|
+
readonly limit?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface MemoryGetRequest {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
}
|
|
66
|
+
export interface MemoryGetResult {
|
|
67
|
+
readonly entry?: MemoryEntryJson;
|
|
68
|
+
readonly found: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface MemoryAddRequest {
|
|
71
|
+
readonly scope: 'global' | 'project' | 'user';
|
|
72
|
+
readonly content: string;
|
|
73
|
+
readonly category?: string;
|
|
74
|
+
readonly projectName?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface MemoryAddResult {
|
|
77
|
+
readonly entry?: MemoryEntryJson;
|
|
78
|
+
readonly error?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface MemoryUpdateRequest {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly content?: string;
|
|
83
|
+
readonly category?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface MemoryUpdateResult {
|
|
86
|
+
readonly entry?: MemoryEntryJson;
|
|
87
|
+
readonly found: boolean;
|
|
88
|
+
readonly error?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface MemoryRemoveRequest {
|
|
91
|
+
readonly id: string;
|
|
92
|
+
}
|
|
93
|
+
export interface MemoryRemoveResult {
|
|
94
|
+
readonly removed: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface MemoryPinRequest {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly pinned: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface MemoryPinResult {
|
|
101
|
+
readonly entry?: MemoryEntryJson;
|
|
102
|
+
readonly found: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface MemoryHealthResult {
|
|
105
|
+
totalEntries: number;
|
|
106
|
+
byScope: {
|
|
107
|
+
global: number;
|
|
108
|
+
project: number;
|
|
109
|
+
user: number;
|
|
110
|
+
};
|
|
111
|
+
pinned: number;
|
|
112
|
+
auditRecords: number;
|
|
113
|
+
lastActivityTs?: number;
|
|
114
|
+
lastExtractionTs?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface MemoryAuditRequest {
|
|
117
|
+
readonly limit?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface MemoryAuditResult {
|
|
120
|
+
readonly entries: readonly AuditEntry[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Remote service exposing the memory store to the client UI. Extends
|
|
124
|
+
* `TypertRemoteService` so the host Typert generator discovers the `@Remote`
|
|
125
|
+
* methods and generates the `./typert` and `./remote` artifacts.
|
|
126
|
+
*/
|
|
127
|
+
export declare class MemoryRemoteService extends TypertRemoteService {
|
|
128
|
+
/** Store the context for internal access (Service.ctx is protected). */
|
|
129
|
+
private readonly _ctx;
|
|
130
|
+
constructor(ctx: Context);
|
|
131
|
+
private memory;
|
|
132
|
+
list(request: MemoryListRequest): MemoryListResult;
|
|
133
|
+
search(request: MemorySearchRequest): {
|
|
134
|
+
entries: readonly MemoryEntryJson[];
|
|
135
|
+
total: number;
|
|
136
|
+
};
|
|
137
|
+
get(request: MemoryGetRequest): MemoryGetResult;
|
|
138
|
+
add(request: MemoryAddRequest): Promise<MemoryAddResult>;
|
|
139
|
+
update(request: MemoryUpdateRequest): Promise<MemoryUpdateResult>;
|
|
140
|
+
remove(request: MemoryRemoveRequest): Promise<MemoryRemoveResult>;
|
|
141
|
+
pin(request: MemoryPinRequest): Promise<MemoryPinResult>;
|
|
142
|
+
health(): MemoryHealthResult;
|
|
143
|
+
auditLog(request: MemoryAuditRequest): MemoryAuditResult;
|
|
144
|
+
}
|
|
145
|
+
export type * from './types.ts';
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/remote/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAU,MAAM,kCAAkC,CAAA;AAE9E,OAAO,KAAK,EAEV,UAAU,EAMX,MAAM,aAAa,CAAA;AAEpB,0BAA0B;AAC1B,eAAO,MAAM,IAAI,kBAAkB,CAAA;AAEnC,sCAAsC;AACtC,eAAO,MAAM,MAAM,UAAa,CAAA;AAEhC,OAAO,QAAQ,qBAAq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B,CAAC,CAetE;IAGK,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAKtE;IAGK,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAQ7D;IAGD,MAAM,IAAI,kBAAkB,CAe3B;IAGD,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAOvD;CACF;AAED,mBAAmB,YAAY,CAAA"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@Remote` service wrapping the `MemoryStore` for the memory management UI (§3.8).
|
|
3
|
+
*
|
|
4
|
+
* This service exposes the store's CRUD operations as `@Remote` methods callable from
|
|
5
|
+
* the client-side UI via `ctx.remote.memory.*`. Writes stay scanner-gated and
|
|
6
|
+
* write-serialized through the existing store contract. The service delegates to
|
|
7
|
+
* `ctx.memory` — it does not duplicate the store.
|
|
8
|
+
*
|
|
9
|
+
* Host integration: the `./remote` subpath must be mounted in `dsh-api-remotes`
|
|
10
|
+
* (see TODO §3.8 verification notes). Write methods should be pinned to loopback
|
|
11
|
+
* via `PRIVILEGED_METHODS`.
|
|
12
|
+
*
|
|
13
|
+
* @module @chenhw7/dsh-memory/remote
|
|
14
|
+
*/
|
|
15
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
16
|
+
var useValue = arguments.length > 2;
|
|
17
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
18
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
19
|
+
}
|
|
20
|
+
return useValue ? value : void 0;
|
|
21
|
+
};
|
|
22
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
23
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
24
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
25
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
26
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
27
|
+
var _, done = false;
|
|
28
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
29
|
+
var context = {};
|
|
30
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
31
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
32
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
33
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
34
|
+
if (kind === "accessor") {
|
|
35
|
+
if (result === void 0) continue;
|
|
36
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
37
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
38
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
39
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
40
|
+
}
|
|
41
|
+
else if (_ = accept(result)) {
|
|
42
|
+
if (kind === "field") initializers.unshift(_);
|
|
43
|
+
else descriptor[key] = _;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
47
|
+
done = true;
|
|
48
|
+
};
|
|
49
|
+
import { TypertRemoteService, Remote } from '@deepseek-ai/dsh-typert-protocol';
|
|
50
|
+
/** Cordis plugin name. */
|
|
51
|
+
export const name = 'memory-remote';
|
|
52
|
+
/** The memory service is required. */
|
|
53
|
+
export const inject = ['memory'];
|
|
54
|
+
/**
|
|
55
|
+
* Cordis function-plugin apply: instantiate the MemoryRemoteService. The
|
|
56
|
+
* TypertRemoteService constructor calls super(ctx, 'memoryRemote') which
|
|
57
|
+
* registers the service on ctx.memoryRemote via Cordis Service.provide.
|
|
58
|
+
* Called by the cordis.patch.yml fifth row.
|
|
59
|
+
*/
|
|
60
|
+
export function apply(ctx) {
|
|
61
|
+
new MemoryRemoteService(ctx);
|
|
62
|
+
}
|
|
63
|
+
function toEntryJson(entry) {
|
|
64
|
+
return {
|
|
65
|
+
id: entry.id,
|
|
66
|
+
scope: entry.scope,
|
|
67
|
+
content: entry.content,
|
|
68
|
+
createdAt: entry.createdAt,
|
|
69
|
+
updatedAt: entry.updatedAt,
|
|
70
|
+
...entry.category !== undefined ? { category: entry.category } : {},
|
|
71
|
+
...entry.projectName !== undefined ? { projectName: entry.projectName } : {},
|
|
72
|
+
...entry.pinned !== undefined ? { pinned: entry.pinned } : {},
|
|
73
|
+
...entry.lastRecalledAt !== undefined ? { lastRecalledAt: entry.lastRecalledAt } : {},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// ─── Service class ──────────────────────────────────────────────────────────
|
|
77
|
+
/**
|
|
78
|
+
* Remote service exposing the memory store to the client UI. Extends
|
|
79
|
+
* `TypertRemoteService` so the host Typert generator discovers the `@Remote`
|
|
80
|
+
* methods and generates the `./typert` and `./remote` artifacts.
|
|
81
|
+
*/
|
|
82
|
+
let MemoryRemoteService = (() => {
|
|
83
|
+
let _classSuper = TypertRemoteService;
|
|
84
|
+
let _instanceExtraInitializers = [];
|
|
85
|
+
let _list_decorators;
|
|
86
|
+
let _search_decorators;
|
|
87
|
+
let _get_decorators;
|
|
88
|
+
let _add_decorators;
|
|
89
|
+
let _update_decorators;
|
|
90
|
+
let _remove_decorators;
|
|
91
|
+
let _pin_decorators;
|
|
92
|
+
let _health_decorators;
|
|
93
|
+
let _auditLog_decorators;
|
|
94
|
+
return class MemoryRemoteService extends _classSuper {
|
|
95
|
+
static {
|
|
96
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
97
|
+
_list_decorators = [Remote('list')];
|
|
98
|
+
_search_decorators = [Remote('search')];
|
|
99
|
+
_get_decorators = [Remote('get')];
|
|
100
|
+
_add_decorators = [Remote('add')];
|
|
101
|
+
_update_decorators = [Remote('update')];
|
|
102
|
+
_remove_decorators = [Remote('remove')];
|
|
103
|
+
_pin_decorators = [Remote('pin')];
|
|
104
|
+
_health_decorators = [Remote('health')];
|
|
105
|
+
_auditLog_decorators = [Remote('auditLog')];
|
|
106
|
+
__esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
107
|
+
__esDecorate(this, null, _search_decorators, { kind: "method", name: "search", static: false, private: false, access: { has: obj => "search" in obj, get: obj => obj.search }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
108
|
+
__esDecorate(this, null, _get_decorators, { kind: "method", name: "get", static: false, private: false, access: { has: obj => "get" in obj, get: obj => obj.get }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
109
|
+
__esDecorate(this, null, _add_decorators, { kind: "method", name: "add", static: false, private: false, access: { has: obj => "add" in obj, get: obj => obj.add }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
110
|
+
__esDecorate(this, null, _update_decorators, { kind: "method", name: "update", static: false, private: false, access: { has: obj => "update" in obj, get: obj => obj.update }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
111
|
+
__esDecorate(this, null, _remove_decorators, { kind: "method", name: "remove", static: false, private: false, access: { has: obj => "remove" in obj, get: obj => obj.remove }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
112
|
+
__esDecorate(this, null, _pin_decorators, { kind: "method", name: "pin", static: false, private: false, access: { has: obj => "pin" in obj, get: obj => obj.pin }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
113
|
+
__esDecorate(this, null, _health_decorators, { kind: "method", name: "health", static: false, private: false, access: { has: obj => "health" in obj, get: obj => obj.health }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
114
|
+
__esDecorate(this, null, _auditLog_decorators, { kind: "method", name: "auditLog", static: false, private: false, access: { has: obj => "auditLog" in obj, get: obj => obj.auditLog }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
115
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
116
|
+
}
|
|
117
|
+
/** Store the context for internal access (Service.ctx is protected). */
|
|
118
|
+
_ctx = __runInitializers(this, _instanceExtraInitializers);
|
|
119
|
+
constructor(ctx) {
|
|
120
|
+
super(ctx, 'memoryRemote');
|
|
121
|
+
this._ctx = ctx;
|
|
122
|
+
}
|
|
123
|
+
memory() {
|
|
124
|
+
return this._ctx.get('memory');
|
|
125
|
+
}
|
|
126
|
+
list(request) {
|
|
127
|
+
const store = this.memory();
|
|
128
|
+
if (store === undefined)
|
|
129
|
+
return { entries: [], total: 0 };
|
|
130
|
+
const scope = request.scope;
|
|
131
|
+
const projectName = request.projectName;
|
|
132
|
+
const all = store.list(scope, projectName);
|
|
133
|
+
const total = all.length;
|
|
134
|
+
const offset = request.offset ?? 0;
|
|
135
|
+
const limit = request.limit ?? 100;
|
|
136
|
+
const paged = limit > 0 ? all.slice(offset, offset + limit) : all.slice(offset);
|
|
137
|
+
return { entries: paged.map(toEntryJson), total };
|
|
138
|
+
}
|
|
139
|
+
search(request) {
|
|
140
|
+
const store = this.memory();
|
|
141
|
+
if (store === undefined)
|
|
142
|
+
return { entries: [], total: 0 };
|
|
143
|
+
const query = buildSearchQuery(request);
|
|
144
|
+
const result = store.search(query);
|
|
145
|
+
return { entries: result.entries.map(toEntryJson), total: result.total };
|
|
146
|
+
}
|
|
147
|
+
get(request) {
|
|
148
|
+
const store = this.memory();
|
|
149
|
+
if (store === undefined)
|
|
150
|
+
return { found: false };
|
|
151
|
+
const entry = store.get(request.id);
|
|
152
|
+
if (entry === undefined)
|
|
153
|
+
return { found: false };
|
|
154
|
+
return { entry: toEntryJson(entry), found: true };
|
|
155
|
+
}
|
|
156
|
+
async add(request) {
|
|
157
|
+
const store = this.memory();
|
|
158
|
+
if (store === undefined)
|
|
159
|
+
return { error: 'memory service not available' };
|
|
160
|
+
try {
|
|
161
|
+
const input = {
|
|
162
|
+
scope: request.scope,
|
|
163
|
+
content: request.content,
|
|
164
|
+
source: 'ui',
|
|
165
|
+
...request.category !== undefined ? { category: request.category } : {},
|
|
166
|
+
...request.projectName !== undefined ? { projectName: request.projectName } : {},
|
|
167
|
+
};
|
|
168
|
+
const { entry } = await store.add(input);
|
|
169
|
+
return { entry: toEntryJson(entry) };
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
return { error: e instanceof Error ? e.message : 'add failed' };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async update(request) {
|
|
176
|
+
const store = this.memory();
|
|
177
|
+
if (store === undefined)
|
|
178
|
+
return { found: false, error: 'memory service not available' };
|
|
179
|
+
try {
|
|
180
|
+
const input = {
|
|
181
|
+
source: 'ui',
|
|
182
|
+
...request.content !== undefined ? { content: request.content } : {},
|
|
183
|
+
...request.category !== undefined ? { category: request.category } : {},
|
|
184
|
+
};
|
|
185
|
+
const updated = await store.update(request.id, input);
|
|
186
|
+
if (updated === undefined)
|
|
187
|
+
return { found: false };
|
|
188
|
+
return { entry: toEntryJson(updated), found: true };
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
return { found: false, error: e instanceof Error ? e.message : 'update failed' };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async remove(request) {
|
|
195
|
+
const store = this.memory();
|
|
196
|
+
if (store === undefined)
|
|
197
|
+
return { removed: false };
|
|
198
|
+
const removed = await store.remove(request.id);
|
|
199
|
+
return { removed };
|
|
200
|
+
}
|
|
201
|
+
async pin(request) {
|
|
202
|
+
const store = this.memory();
|
|
203
|
+
if (store === undefined)
|
|
204
|
+
return { found: false };
|
|
205
|
+
const entry = request.pinned
|
|
206
|
+
? await store.pin(request.id)
|
|
207
|
+
: await store.unpin(request.id);
|
|
208
|
+
if (entry === undefined)
|
|
209
|
+
return { found: false };
|
|
210
|
+
return { entry: toEntryJson(entry), found: true };
|
|
211
|
+
}
|
|
212
|
+
health() {
|
|
213
|
+
const store = this.memory();
|
|
214
|
+
if (store === undefined) {
|
|
215
|
+
return { totalEntries: 0, byScope: { global: 0, project: 0, user: 0 }, pinned: 0, auditRecords: 0 };
|
|
216
|
+
}
|
|
217
|
+
const h = store.health();
|
|
218
|
+
const result = {
|
|
219
|
+
totalEntries: h.totalEntries,
|
|
220
|
+
byScope: h.byScope,
|
|
221
|
+
pinned: h.pinned,
|
|
222
|
+
auditRecords: h.auditRecords,
|
|
223
|
+
};
|
|
224
|
+
if (h.lastActivityTs !== undefined)
|
|
225
|
+
result.lastActivityTs = h.lastActivityTs;
|
|
226
|
+
if (h.lastExtractionTs !== undefined)
|
|
227
|
+
result.lastExtractionTs = h.lastExtractionTs;
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
auditLog(request) {
|
|
231
|
+
const store = this.memory();
|
|
232
|
+
if (store === undefined)
|
|
233
|
+
return { entries: [] };
|
|
234
|
+
const all = store.exportAuditLog();
|
|
235
|
+
const limit = request.limit ?? 100;
|
|
236
|
+
const entries = limit > 0 ? all.slice(-limit) : all;
|
|
237
|
+
return { entries };
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
})();
|
|
241
|
+
export { MemoryRemoteService };
|
|
242
|
+
/** Build a MemorySearchQuery without triggering exactOptionalPropertyTypes. */
|
|
243
|
+
function buildSearchQuery(request) {
|
|
244
|
+
const query = {};
|
|
245
|
+
if (request.scope !== undefined)
|
|
246
|
+
query.scope = request.scope;
|
|
247
|
+
if (request.category !== undefined)
|
|
248
|
+
query.category = request.category;
|
|
249
|
+
if (request.projectName !== undefined)
|
|
250
|
+
query.projectName = request.projectName;
|
|
251
|
+
if (request.query !== undefined)
|
|
252
|
+
query.query = request.query;
|
|
253
|
+
if (request.limit !== undefined)
|
|
254
|
+
query.limit = request.limit;
|
|
255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import type {
|
|
2
|
+
RemoteResult,
|
|
3
|
+
TypertRemoteContribution,
|
|
4
|
+
} from '@deepseek-ai/dsh-typert-protocol'
|
|
5
|
+
|
|
6
|
+
// Wire types (mirrors src/remote/types.ts but client-safe)
|
|
7
|
+
export interface MemoryEntryJson {
|
|
8
|
+
id: string
|
|
9
|
+
scope: 'global' | 'project' | 'user'
|
|
10
|
+
category?: string
|
|
11
|
+
content: string
|
|
12
|
+
projectName?: string
|
|
13
|
+
createdAt: number
|
|
14
|
+
updatedAt: number
|
|
15
|
+
pinned?: boolean
|
|
16
|
+
lastRecalledAt?: number
|
|
17
|
+
}
|
|
18
|
+
export interface MemoryListResult { entries: readonly MemoryEntryJson[]; total: number }
|
|
19
|
+
export interface MemorySearchResult { entries: readonly MemoryEntryJson[]; total: number }
|
|
20
|
+
export interface MemoryGetResult { entry?: MemoryEntryJson; found: boolean }
|
|
21
|
+
export interface MemoryAddResult { entry?: MemoryEntryJson; error?: string }
|
|
22
|
+
export interface MemoryUpdateResult { entry?: MemoryEntryJson; found: boolean; error?: string }
|
|
23
|
+
export interface MemoryRemoveResult { removed: boolean }
|
|
24
|
+
export interface MemoryPinResult { entry?: MemoryEntryJson; found: boolean }
|
|
25
|
+
export interface MemoryHealthResult {
|
|
26
|
+
totalEntries: number
|
|
27
|
+
byScope: { global: number; project: number; user: number }
|
|
28
|
+
pinned: number
|
|
29
|
+
auditRecords: number
|
|
30
|
+
lastActivityTs?: number
|
|
31
|
+
lastExtractionTs?: number
|
|
32
|
+
}
|
|
33
|
+
export interface AuditEntryJson {
|
|
34
|
+
id: string
|
|
35
|
+
op: 'add' | 'update' | 'remove'
|
|
36
|
+
entryId: string
|
|
37
|
+
scope: 'global' | 'project' | 'user'
|
|
38
|
+
category?: string
|
|
39
|
+
source: 'tool' | 'review' | 'flush' | 'ui'
|
|
40
|
+
sessionId?: string
|
|
41
|
+
ts: number
|
|
42
|
+
contentPreview: string
|
|
43
|
+
}
|
|
44
|
+
export interface MemoryAuditResult { entries: readonly AuditEntryJson[] }
|
|
45
|
+
|
|
46
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
47
|
+
interface TypertRemoteNamespace$6d656d6f727952656d6f7465 {
|
|
48
|
+
list: (request: { scope?: string; projectName?: string; limit?: number; offset?: number }) => Promise<RemoteResult<MemoryListResult>>
|
|
49
|
+
search: (request: { scope?: string; category?: string; projectName?: string; query?: string; limit?: number }) => Promise<RemoteResult<MemorySearchResult>>
|
|
50
|
+
get: (request: { id: string }) => Promise<RemoteResult<MemoryGetResult>>
|
|
51
|
+
add: (request: { scope: string; content: string; category?: string; projectName?: string }) => Promise<RemoteResult<MemoryAddResult>>
|
|
52
|
+
update: (request: { id: string; content?: string; category?: string }) => Promise<RemoteResult<MemoryUpdateResult>>
|
|
53
|
+
remove: (request: { id: string }) => Promise<RemoteResult<MemoryRemoveResult>>
|
|
54
|
+
pin: (request: { id: string; pinned: boolean }) => Promise<RemoteResult<MemoryPinResult>>
|
|
55
|
+
health: () => Promise<RemoteResult<MemoryHealthResult>>
|
|
56
|
+
auditLog: (request: { limit?: number }) => Promise<RemoteResult<MemoryAuditResult>>
|
|
57
|
+
}
|
|
58
|
+
interface TypertRemoteMap {
|
|
59
|
+
'memoryRemote/list': (request: { scope?: string; projectName?: string; limit?: number; offset?: number }) => Promise<RemoteResult<MemoryListResult>>
|
|
60
|
+
'memoryRemote/search': (request: { scope?: string; category?: string; projectName?: string; query?: string; limit?: number }) => Promise<RemoteResult<MemorySearchResult>>
|
|
61
|
+
'memoryRemote/get': (request: { id: string }) => Promise<RemoteResult<MemoryGetResult>>
|
|
62
|
+
'memoryRemote/add': (request: { scope: string; content: string; category?: string; projectName?: string }) => Promise<RemoteResult<MemoryAddResult>>
|
|
63
|
+
'memoryRemote/update': (request: { id: string; content?: string; category?: string }) => Promise<RemoteResult<MemoryUpdateResult>>
|
|
64
|
+
'memoryRemote/remove': (request: { id: string }) => Promise<RemoteResult<MemoryRemoveResult>>
|
|
65
|
+
'memoryRemote/pin': (request: { id: string; pinned: boolean }) => Promise<RemoteResult<MemoryPinResult>>
|
|
66
|
+
'memoryRemote/health': () => Promise<RemoteResult<MemoryHealthResult>>
|
|
67
|
+
'memoryRemote/auditLog': (request: { limit?: number }) => Promise<RemoteResult<MemoryAuditResult>>
|
|
68
|
+
}
|
|
69
|
+
interface TypertRemoteNamespaceMap {
|
|
70
|
+
'memoryRemote': TypertRemoteNamespace$6d656d6f727952656d6f7465
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare const TYPERT_REMOTE: TypertRemoteContribution
|
|
75
|
+
export default TYPERT_REMOTE
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written Typert remote-client contribution for the MemoryRemoteService.
|
|
3
|
+
*
|
|
4
|
+
* Normally this file is generated by @deepseek-ai/dsh-typert-generator from
|
|
5
|
+
* the @Remote decorators in src/remote/index.ts. Since dsh-memory uses tsc
|
|
6
|
+
* (not tsdown) and is an external sibling to the harness workspace, the
|
|
7
|
+
* generator does not discover it. This file provides the equivalent
|
|
8
|
+
* TypertRemoteContribution manually.
|
|
9
|
+
*
|
|
10
|
+
* The descriptors mirror the @Remote('method') declarations in
|
|
11
|
+
* src/remote/index.ts. When the package is eventually moved into the host
|
|
12
|
+
* workspace and built with tsdown, this file can be replaced by the generated
|
|
13
|
+
* artifact.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Schemas are minimal — the Gateway uses them for validation, but our methods
|
|
17
|
+
// accept simple JSON objects. We use zod for the schema shape the Gateway expects.
|
|
18
|
+
import { z } from 'zod'
|
|
19
|
+
|
|
20
|
+
const _list_param = z.object({}).passthrough()
|
|
21
|
+
const _list_result = z.object({}).passthrough()
|
|
22
|
+
const _search_param = z.object({}).passthrough()
|
|
23
|
+
const _search_result = z.object({}).passthrough()
|
|
24
|
+
const _get_param = z.object({}).passthrough()
|
|
25
|
+
const _get_result = z.object({}).passthrough()
|
|
26
|
+
const _add_param = z.object({}).passthrough()
|
|
27
|
+
const _add_result = z.object({}).passthrough()
|
|
28
|
+
const _update_param = z.object({}).passthrough()
|
|
29
|
+
const _update_result = z.object({}).passthrough()
|
|
30
|
+
const _remove_param = z.object({}).passthrough()
|
|
31
|
+
const _remove_result = z.object({}).passthrough()
|
|
32
|
+
const _pin_param = z.object({}).passthrough()
|
|
33
|
+
const _pin_result = z.object({}).passthrough()
|
|
34
|
+
// health() takes no request parameter — no _health_param schema needed.
|
|
35
|
+
const _health_result = z.object({}).passthrough()
|
|
36
|
+
const _auditLog_param = z.object({}).passthrough()
|
|
37
|
+
const _auditLog_result = z.object({}).passthrough()
|
|
38
|
+
|
|
39
|
+
const pkg = '@chenhw7/dsh-memory'
|
|
40
|
+
const ns = 'memoryRemote'
|
|
41
|
+
|
|
42
|
+
const descriptors = [
|
|
43
|
+
{ id: `${pkg}#${ns}/list`, service: ns, namespace: ns, method: 'list', invocation: { kind: 'direct' },
|
|
44
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryListRequest`, schema: _list_param } }],
|
|
45
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryListResult`, schema: _list_result },
|
|
46
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
47
|
+
{ id: `${pkg}#${ns}/search`, service: ns, namespace: ns, method: 'search', invocation: { kind: 'direct' },
|
|
48
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemorySearchRequest`, schema: _search_param } }],
|
|
49
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemorySearchResult`, schema: _search_result },
|
|
50
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
51
|
+
{ id: `${pkg}#${ns}/get`, service: ns, namespace: ns, method: 'get', invocation: { kind: 'direct' },
|
|
52
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryGetRequest`, schema: _get_param } }],
|
|
53
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryGetResult`, schema: _get_result },
|
|
54
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
55
|
+
{ id: `${pkg}#${ns}/add`, service: ns, namespace: ns, method: 'add', invocation: { kind: 'direct' },
|
|
56
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryAddRequest`, schema: _add_param } }],
|
|
57
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryAddResult`, schema: _add_result },
|
|
58
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
59
|
+
{ id: `${pkg}#${ns}/update`, service: ns, namespace: ns, method: 'update', invocation: { kind: 'direct' },
|
|
60
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryUpdateRequest`, schema: _update_param } }],
|
|
61
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryUpdateResult`, schema: _update_result },
|
|
62
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
63
|
+
{ id: `${pkg}#${ns}/remove`, service: ns, namespace: ns, method: 'remove', invocation: { kind: 'direct' },
|
|
64
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryRemoveRequest`, schema: _remove_param } }],
|
|
65
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryRemoveResult`, schema: _remove_result },
|
|
66
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
67
|
+
{ id: `${pkg}#${ns}/pin`, service: ns, namespace: ns, method: 'pin', invocation: { kind: 'direct' },
|
|
68
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryPinRequest`, schema: _pin_param } }],
|
|
69
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryPinResult`, schema: _pin_result },
|
|
70
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
71
|
+
{ id: `${pkg}#${ns}/health`, service: ns, namespace: ns, method: 'health', invocation: { kind: 'direct' },
|
|
72
|
+
// health() declares no request parameter — empty parameters array matches
|
|
73
|
+
// the host method signature so the gateway's assertExactArguments accepts
|
|
74
|
+
// an empty args object.
|
|
75
|
+
parameters: [],
|
|
76
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryHealthResult`, schema: _health_result },
|
|
77
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
78
|
+
{ id: `${pkg}#${ns}/auditLog`, service: ns, namespace: ns, method: 'auditLog', invocation: { kind: 'direct' },
|
|
79
|
+
parameters: [{ name: 'request', wire: 'request', source: 'json', codec: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryAuditRequest`, schema: _auditLog_param } }],
|
|
80
|
+
result: { mode: 'strict', typeSymbol: `${pkg}/remote/types#MemoryAuditResult`, schema: _auditLog_result },
|
|
81
|
+
sourceLocation: { file: 'src/remote/index.ts', line: 0, column: 0 } },
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
const TYPERT_REMOTE = { package: pkg, descriptors }
|
|
85
|
+
|
|
86
|
+
export default TYPERT_REMOTE
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the MemoryRemoteService (§3.8). These are the request/result
|
|
3
|
+
* interfaces exposed through `@Remote` methods. The Typert generator reads
|
|
4
|
+
* type symbols from this module's export surface.
|
|
5
|
+
*
|
|
6
|
+
* @module @chenhw7/dsh-memory/remote/types
|
|
7
|
+
*/
|
|
8
|
+
export type { MemoryEntryJson, MemoryListRequest, MemoryListResult, MemorySearchRequest, MemoryGetRequest, MemoryGetResult, MemoryAddRequest, MemoryAddResult, MemoryUpdateRequest, MemoryUpdateResult, MemoryRemoveRequest, MemoryRemoveResult, MemoryPinRequest, MemoryPinResult, MemoryHealthResult, MemoryAuditRequest, MemoryAuditResult, } from './index.ts';
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/remote/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the MemoryRemoteService (§3.8). These are the request/result
|
|
3
|
+
* interfaces exposed through `@Remote` methods. The Typert generator reads
|
|
4
|
+
* type symbols from this module's export surface.
|
|
5
|
+
*
|
|
6
|
+
* @module @chenhw7/dsh-memory/remote/types
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/remote/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|