@klarkxy/dsh-memory 0.1.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.
- package/LICENSE +41 -0
- package/README.md +40 -0
- package/cordis.patch.yml +5 -0
- package/docs/README.zh-CN.md +9 -0
- package/lib/client.inner.cjs +1036 -0
- package/lib/client.inner.cjs.map +1 -0
- package/lib/client.js +1206 -0
- package/lib/contracts.d.ts +122 -0
- package/lib/contracts.js +81 -0
- package/lib/contracts.js.map +1 -0
- package/lib/index.d.ts +110 -0
- package/lib/index.js +1515 -0
- package/lib/index.js.map +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AiFeatureScope, AiServices, AuxiliaryRequest, AuxiliaryResult, EvidenceRef, KnowledgeKind, KnowledgeScope, MemoryQuery, MemoryRecord, MemoryService, NewMemoryRecord, ProducerMessageSource, PurposeSpec, RpcResult, UsageReceipt, projectIdFromCwd as projectIdFromCwd$1 } from "@klarkxy/dsh-ai-services/contracts";
|
|
2
|
+
//#region src/contracts.d.ts
|
|
3
|
+
/** Frozen shared chat-events seat. Must stay equal to @klarkxy/dsh-ai-services CHAT_EVENTS_SLOT. */
|
|
4
|
+
declare const CHAT_EVENTS_SLOT = "dsh-editor.chat.events";
|
|
5
|
+
/** Shared untruncated cwd identity. Drive roots (`/` / `C:/`) stay intact. */
|
|
6
|
+
declare const projectIdFromCwd: typeof projectIdFromCwd$1;
|
|
7
|
+
declare const MEMORY_PLUGIN = "@klarkxy/dsh-memory";
|
|
8
|
+
declare const MEMORY_SOURCE_KIND: "plugin:@klarkxy/dsh-memory";
|
|
9
|
+
declare const MEMORY_RPC_CHANNEL = "/dsh-memory";
|
|
10
|
+
declare const MEMORY_DREAM_PURPOSE = "memory.dream";
|
|
11
|
+
declare const MEMORY_INJECTION_SECTION = "dsh-memory:recall";
|
|
12
|
+
/** Frozen pluginName now accepts scoped ids. */
|
|
13
|
+
declare const MEMORY_ACTIVATE_ID = "@klarkxy/dsh-memory";
|
|
14
|
+
declare const DEFAULT_IDLE_MS: number;
|
|
15
|
+
declare const MIN_IDLE_MS = 60000;
|
|
16
|
+
declare const MAX_IDLE_MS: number;
|
|
17
|
+
declare const DREAM_MIN_INTERVAL_MS: number;
|
|
18
|
+
declare const DREAM_MIN_MATERIAL = 3;
|
|
19
|
+
declare const MIN_RECALL_RECORDS = 1;
|
|
20
|
+
declare const MAX_RECALL_RECORDS = 5;
|
|
21
|
+
declare const MAX_RECALL_TOKENS = 800;
|
|
22
|
+
declare const MAX_PROJECT_ID_CHARS = 32768;
|
|
23
|
+
declare const INJECT_KINDS: readonly KnowledgeKind[];
|
|
24
|
+
declare const RECALL_EXCLUDED_STATUSES: readonly MemoryRecord['status'][];
|
|
25
|
+
interface MemorySettings {
|
|
26
|
+
revision: number;
|
|
27
|
+
injectEnabled: boolean;
|
|
28
|
+
dreamIdleEnabled: boolean;
|
|
29
|
+
idleMs: number;
|
|
30
|
+
}
|
|
31
|
+
declare const defaultSettings: () => MemorySettings;
|
|
32
|
+
type DreamPlanStatus = 'preview' | 'applied' | 'cancelled' | 'stale' | 'failed' | 'noop';
|
|
33
|
+
interface DreamSnapshotEntry {
|
|
34
|
+
id: string;
|
|
35
|
+
revision: number;
|
|
36
|
+
status: MemoryRecord['status'];
|
|
37
|
+
scope: KnowledgeScope;
|
|
38
|
+
expiresAt?: number;
|
|
39
|
+
}
|
|
40
|
+
interface DreamProposal {
|
|
41
|
+
title: string;
|
|
42
|
+
content: string;
|
|
43
|
+
kind: Exclude<KnowledgeKind, 'lesson'>;
|
|
44
|
+
tags: string[];
|
|
45
|
+
exceptions: string[];
|
|
46
|
+
evidence: EvidenceRef[];
|
|
47
|
+
sourceIds: string[];
|
|
48
|
+
scope: KnowledgeScope;
|
|
49
|
+
}
|
|
50
|
+
interface DreamPlan {
|
|
51
|
+
id: string;
|
|
52
|
+
revision: number;
|
|
53
|
+
sessionId: string;
|
|
54
|
+
projectId?: string;
|
|
55
|
+
status: DreamPlanStatus;
|
|
56
|
+
sourceVersion: string;
|
|
57
|
+
snapshot: DreamSnapshotEntry[];
|
|
58
|
+
proposals: DreamProposal[];
|
|
59
|
+
generation: number;
|
|
60
|
+
createdAt: number;
|
|
61
|
+
updatedAt: number;
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
interface MemoryTombstone {
|
|
65
|
+
id: string;
|
|
66
|
+
deletedAt: number;
|
|
67
|
+
lastRevision: number;
|
|
68
|
+
}
|
|
69
|
+
interface MemoryPersistedState {
|
|
70
|
+
settings: MemorySettings;
|
|
71
|
+
records: MemoryRecord[];
|
|
72
|
+
tombstones: MemoryTombstone[];
|
|
73
|
+
dreams: DreamPlan[];
|
|
74
|
+
lastAttemptAt?: number;
|
|
75
|
+
}
|
|
76
|
+
interface MemoryStatus {
|
|
77
|
+
runningDreams?: string[];
|
|
78
|
+
settings: MemorySettings;
|
|
79
|
+
records: MemoryRecord[];
|
|
80
|
+
dreams: DreamPlan[];
|
|
81
|
+
projectId?: string;
|
|
82
|
+
storageFailed: boolean;
|
|
83
|
+
aiAvailable: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** Matches frozen MemoryService optional mutation identity/lifetime guards. */
|
|
86
|
+
interface MemoryMutationOptions {
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
isCurrent?: () => boolean;
|
|
89
|
+
}
|
|
90
|
+
interface PreStepEnter {
|
|
91
|
+
kind: 'enter';
|
|
92
|
+
messages: unknown[];
|
|
93
|
+
startsRequestSeries?: true;
|
|
94
|
+
}
|
|
95
|
+
type PreStepDecision = {
|
|
96
|
+
kind: 'reject';
|
|
97
|
+
} | PreStepEnter;
|
|
98
|
+
interface InjectedMemoryMessage {
|
|
99
|
+
content: Array<{
|
|
100
|
+
type: 'text';
|
|
101
|
+
text: string;
|
|
102
|
+
}>;
|
|
103
|
+
source: ProducerMessageSource & {
|
|
104
|
+
kind: typeof MEMORY_SOURCE_KIND;
|
|
105
|
+
plugin: typeof MEMORY_PLUGIN;
|
|
106
|
+
form: 'snapshot';
|
|
107
|
+
sections: Array<{
|
|
108
|
+
name: string;
|
|
109
|
+
text: string;
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
declare function fail<T = never>(code: string, message: string): RpcResult<T>;
|
|
114
|
+
declare function ok<T>(value: T): RpcResult<T>;
|
|
115
|
+
declare function parseSessionId(payload: unknown): string | undefined;
|
|
116
|
+
declare function sessionCwd(session: unknown): string | undefined;
|
|
117
|
+
declare function scopesEqual(left: KnowledgeScope, right: KnowledgeScope): boolean;
|
|
118
|
+
declare function scopeKey(scope: KnowledgeScope): string;
|
|
119
|
+
declare function cloneRecord(record: MemoryRecord): MemoryRecord;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { type AiFeatureScope, type AiServices, type AuxiliaryRequest, type AuxiliaryResult, CHAT_EVENTS_SLOT, DEFAULT_IDLE_MS, DREAM_MIN_INTERVAL_MS, DREAM_MIN_MATERIAL, DreamPlan, DreamPlanStatus, DreamProposal, DreamSnapshotEntry, type EvidenceRef, INJECT_KINDS, InjectedMemoryMessage, type KnowledgeKind, type KnowledgeScope, MAX_IDLE_MS, MAX_PROJECT_ID_CHARS, MAX_RECALL_RECORDS, MAX_RECALL_TOKENS, MEMORY_ACTIVATE_ID, MEMORY_DREAM_PURPOSE, MEMORY_INJECTION_SECTION, MEMORY_PLUGIN, MEMORY_RPC_CHANNEL, MEMORY_SOURCE_KIND, MIN_IDLE_MS, MIN_RECALL_RECORDS, MemoryMutationOptions, MemoryPersistedState, type MemoryQuery, type MemoryRecord, type MemoryService, MemorySettings, MemoryStatus, MemoryTombstone, type NewMemoryRecord, PreStepDecision, PreStepEnter, type ProducerMessageSource, type PurposeSpec, RECALL_EXCLUDED_STATUSES, type RpcResult, type UsageReceipt, cloneRecord, defaultSettings, fail, ok, parseSessionId, projectIdFromCwd, scopeKey, scopesEqual, sessionCwd };
|
|
122
|
+
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CHAT_EVENTS_SLOT as CHAT_EVENTS_SLOT$1, projectIdFromCwd as projectIdFromCwd$1 } from "@klarkxy/dsh-ai-services/contracts";
|
|
2
|
+
//#region src/contracts.ts
|
|
3
|
+
/** Browser-safe contracts. MemoryRecord / MemoryService match frozen @klarkxy/dsh-ai-services. */
|
|
4
|
+
/** Frozen shared chat-events seat. Must stay equal to @klarkxy/dsh-ai-services CHAT_EVENTS_SLOT. */
|
|
5
|
+
const CHAT_EVENTS_SLOT = CHAT_EVENTS_SLOT$1;
|
|
6
|
+
/** Shared untruncated cwd identity. Drive roots (`/` / `C:/`) stay intact. */
|
|
7
|
+
const projectIdFromCwd = projectIdFromCwd$1;
|
|
8
|
+
const MEMORY_PLUGIN = "@klarkxy/dsh-memory";
|
|
9
|
+
const MEMORY_SOURCE_KIND = "plugin:@klarkxy/dsh-memory";
|
|
10
|
+
const MEMORY_RPC_CHANNEL = "/dsh-memory";
|
|
11
|
+
const MEMORY_DREAM_PURPOSE = "memory.dream";
|
|
12
|
+
const MEMORY_INJECTION_SECTION = "dsh-memory:recall";
|
|
13
|
+
/** Frozen pluginName now accepts scoped ids. */
|
|
14
|
+
const MEMORY_ACTIVATE_ID = MEMORY_PLUGIN;
|
|
15
|
+
const DEFAULT_IDLE_MS = 9e5;
|
|
16
|
+
const MIN_IDLE_MS = 6e4;
|
|
17
|
+
const MAX_IDLE_MS = 108e5;
|
|
18
|
+
const DREAM_MIN_INTERVAL_MS = 864e5;
|
|
19
|
+
const DREAM_MIN_MATERIAL = 3;
|
|
20
|
+
const MIN_RECALL_RECORDS = 1;
|
|
21
|
+
const MAX_RECALL_RECORDS = 5;
|
|
22
|
+
const MAX_RECALL_TOKENS = 800;
|
|
23
|
+
const MAX_PROJECT_ID_CHARS = 32768;
|
|
24
|
+
const INJECT_KINDS = [
|
|
25
|
+
"preference",
|
|
26
|
+
"project-fact",
|
|
27
|
+
"decision"
|
|
28
|
+
];
|
|
29
|
+
const RECALL_EXCLUDED_STATUSES = [
|
|
30
|
+
"candidate",
|
|
31
|
+
"rejected",
|
|
32
|
+
"revoked",
|
|
33
|
+
"deleted",
|
|
34
|
+
"superseded"
|
|
35
|
+
];
|
|
36
|
+
const defaultSettings = () => ({
|
|
37
|
+
revision: 0,
|
|
38
|
+
injectEnabled: true,
|
|
39
|
+
dreamIdleEnabled: true,
|
|
40
|
+
idleMs: DEFAULT_IDLE_MS
|
|
41
|
+
});
|
|
42
|
+
function fail(code, message) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
error: {
|
|
46
|
+
code,
|
|
47
|
+
message
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function ok(value) {
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
value
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function parseSessionId(payload) {
|
|
58
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return void 0;
|
|
59
|
+
const sessionId = payload.sessionId;
|
|
60
|
+
return typeof sessionId === "string" && sessionId.length > 0 && sessionId.length <= 200 ? sessionId : void 0;
|
|
61
|
+
}
|
|
62
|
+
function sessionCwd(session) {
|
|
63
|
+
if (!session || typeof session !== "object") return void 0;
|
|
64
|
+
const row = session;
|
|
65
|
+
const cwd = row.meta?.cwd ?? row.header?.cwd;
|
|
66
|
+
return typeof cwd === "string" ? cwd : void 0;
|
|
67
|
+
}
|
|
68
|
+
function scopesEqual(left, right) {
|
|
69
|
+
if (left.kind === "global") return right.kind === "global";
|
|
70
|
+
return right.kind === "project" && left.projectId === right.projectId;
|
|
71
|
+
}
|
|
72
|
+
function scopeKey(scope) {
|
|
73
|
+
return scope.kind === "global" ? "global" : `project:${scope.projectId}`;
|
|
74
|
+
}
|
|
75
|
+
function cloneRecord(record) {
|
|
76
|
+
return structuredClone(record);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { CHAT_EVENTS_SLOT, DEFAULT_IDLE_MS, DREAM_MIN_INTERVAL_MS, DREAM_MIN_MATERIAL, INJECT_KINDS, MAX_IDLE_MS, MAX_PROJECT_ID_CHARS, MAX_RECALL_RECORDS, MAX_RECALL_TOKENS, MEMORY_ACTIVATE_ID, MEMORY_DREAM_PURPOSE, MEMORY_INJECTION_SECTION, MEMORY_PLUGIN, MEMORY_RPC_CHANNEL, MEMORY_SOURCE_KIND, MIN_IDLE_MS, MIN_RECALL_RECORDS, RECALL_EXCLUDED_STATUSES, cloneRecord, defaultSettings, fail, ok, parseSessionId, projectIdFromCwd, scopeKey, scopesEqual, sessionCwd };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","names":["FROZEN_CHAT_EVENTS_SLOT","frozenProjectIdFromCwd"],"sources":["../src/contracts.ts"],"sourcesContent":["/** Browser-safe contracts. MemoryRecord / MemoryService match frozen @klarkxy/dsh-ai-services. */\nimport {\n CHAT_EVENTS_SLOT as FROZEN_CHAT_EVENTS_SLOT,\n projectIdFromCwd as frozenProjectIdFromCwd,\n} from '@klarkxy/dsh-ai-services/contracts'\nimport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n} from '@klarkxy/dsh-ai-services/contracts'\n\nexport type {\n AiFeatureScope,\n AiServices,\n AuxiliaryRequest,\n AuxiliaryResult,\n EvidenceRef,\n KnowledgeKind,\n KnowledgeScope,\n MemoryQuery,\n MemoryRecord,\n MemoryService,\n NewMemoryRecord,\n PurposeSpec,\n ProducerMessageSource,\n RpcResult,\n UsageReceipt,\n}\n\n/** Frozen shared chat-events seat. Must stay equal to @klarkxy/dsh-ai-services CHAT_EVENTS_SLOT. */\nexport const CHAT_EVENTS_SLOT = FROZEN_CHAT_EVENTS_SLOT\n/** Shared untruncated cwd identity. Drive roots (`/` / `C:/`) stay intact. */\nexport const projectIdFromCwd = frozenProjectIdFromCwd\nexport const MEMORY_PLUGIN = '@klarkxy/dsh-memory'\nexport const MEMORY_SOURCE_KIND = 'plugin:@klarkxy/dsh-memory' as const\nexport const MEMORY_RPC_CHANNEL = '/dsh-memory'\nexport const MEMORY_DREAM_PURPOSE = 'memory.dream'\nexport const MEMORY_INJECTION_SECTION = 'dsh-memory:recall'\n/** Frozen pluginName now accepts scoped ids. */\nexport const MEMORY_ACTIVATE_ID = MEMORY_PLUGIN\n\nexport const DEFAULT_IDLE_MS = 15 * 60 * 1000\nexport const MIN_IDLE_MS = 60_000\nexport const MAX_IDLE_MS = 180 * 60_000\nexport const DREAM_MIN_INTERVAL_MS = 24 * 60 * 60 * 1000\nexport const DREAM_MIN_MATERIAL = 3\nexport const MIN_RECALL_RECORDS = 1\nexport const MAX_RECALL_RECORDS = 5\nexport const MAX_RECALL_TOKENS = 800\nexport const MAX_PROJECT_ID_CHARS = 32_768\nexport const INJECT_KINDS: readonly KnowledgeKind[] = ['preference', 'project-fact', 'decision']\nexport const RECALL_EXCLUDED_STATUSES: readonly MemoryRecord['status'][] = [\n 'candidate', 'rejected', 'revoked', 'deleted', 'superseded',\n]\n\nexport interface MemorySettings {\n revision: number\n injectEnabled: boolean\n dreamIdleEnabled: boolean\n idleMs: number\n}\n\nexport const defaultSettings = (): MemorySettings => ({\n revision: 0,\n injectEnabled: true,\n dreamIdleEnabled: true,\n idleMs: DEFAULT_IDLE_MS,\n})\n\nexport type DreamPlanStatus = 'preview' | 'applied' | 'cancelled' | 'stale' | 'failed' | 'noop'\n\nexport interface DreamSnapshotEntry {\n id: string\n revision: number\n status: MemoryRecord['status']\n scope: KnowledgeScope\n expiresAt?: number\n}\n\nexport interface DreamProposal {\n title: string\n content: string\n kind: Exclude<KnowledgeKind, 'lesson'>\n tags: string[]\n exceptions: string[]\n evidence: EvidenceRef[]\n sourceIds: string[]\n scope: KnowledgeScope\n}\n\nexport interface DreamPlan {\n id: string\n revision: number\n sessionId: string\n projectId?: string\n status: DreamPlanStatus\n sourceVersion: string\n snapshot: DreamSnapshotEntry[]\n proposals: DreamProposal[]\n generation: number\n createdAt: number\n updatedAt: number\n error?: string\n}\n\nexport interface MemoryTombstone {\n id: string\n deletedAt: number\n lastRevision: number\n}\n\nexport interface MemoryPersistedState {\n settings: MemorySettings\n records: MemoryRecord[]\n tombstones: MemoryTombstone[]\n dreams: DreamPlan[]\n lastAttemptAt?: number\n}\n\nexport interface MemoryStatus {\n runningDreams?: string[]\n settings: MemorySettings\n records: MemoryRecord[]\n dreams: DreamPlan[]\n projectId?: string\n storageFailed: boolean\n aiAvailable: boolean\n}\n\n/** Matches frozen MemoryService optional mutation identity/lifetime guards. */\nexport interface MemoryMutationOptions { signal?: AbortSignal; isCurrent?: () => boolean }\n\nexport interface PreStepEnter {\n kind: 'enter'\n messages: unknown[]\n startsRequestSeries?: true\n}\nexport type PreStepDecision = { kind: 'reject' } | PreStepEnter\n\nexport interface InjectedMemoryMessage {\n content: Array<{ type: 'text'; text: string }>\n source: ProducerMessageSource & {\n kind: typeof MEMORY_SOURCE_KIND\n plugin: typeof MEMORY_PLUGIN\n form: 'snapshot'\n sections: Array<{ name: string; text: string }>\n }\n}\n\nexport function fail<T = never>(code: string, message: string): RpcResult<T> {\n return { ok: false, error: { code, message } }\n}\n\nexport function ok<T>(value: T): RpcResult<T> {\n return { ok: true, value }\n}\n\nexport function parseSessionId(payload: unknown): string | undefined {\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return undefined\n const sessionId = (payload as { sessionId?: unknown }).sessionId\n return typeof sessionId === 'string' && sessionId.length > 0 && sessionId.length <= 200 ? sessionId : undefined\n}\n\nexport function sessionCwd(session: unknown): string | undefined {\n if (!session || typeof session !== 'object') return undefined\n const row = session as { meta?: { cwd?: unknown }; header?: { cwd?: unknown } }\n const cwd = row.meta?.cwd ?? row.header?.cwd\n return typeof cwd === 'string' ? cwd : undefined\n}\n\nexport function scopesEqual(left: KnowledgeScope, right: KnowledgeScope): boolean {\n if (left.kind === 'global') return right.kind === 'global'\n return right.kind === 'project' && left.projectId === right.projectId\n}\n\nexport function scopeKey(scope: KnowledgeScope): string {\n return scope.kind === 'global' ? 'global' : `project:${scope.projectId}`\n}\n\nexport function cloneRecord(record: MemoryRecord): MemoryRecord {\n return structuredClone(record)\n}\n"],"mappings":";;;;AA0CA,MAAa,mBAAmBA;;AAEhC,MAAa,mBAAmBC;AAChC,MAAa,gBAAgB;AAC7B,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,uBAAuB;AACpC,MAAa,2BAA2B;;AAExC,MAAa,qBAAqB;AAElC,MAAa,kBAAkB;AAC/B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAC3B,MAAa,wBAAwB;AACrC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AACpC,MAAa,eAAyC;CAAC;CAAc;CAAgB;AAAU;AAC/F,MAAa,2BAA8D;CACzE;CAAa;CAAY;CAAW;CAAW;AACjD;AASA,MAAa,yBAAyC;CACpD,UAAU;CACV,eAAe;CACf,kBAAkB;CAClB,QAAQ;AACV;AAkFA,SAAgB,KAAgB,MAAc,SAA+B;CAC3E,OAAO;EAAE,IAAI;EAAO,OAAO;GAAE;GAAM;EAAQ;CAAE;AAC/C;AAEA,SAAgB,GAAM,OAAwB;CAC5C,OAAO;EAAE,IAAI;EAAM;CAAM;AAC3B;AAEA,SAAgB,eAAe,SAAsC;CACnE,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG,OAAO,KAAA;CAC9E,MAAM,YAAa,QAAoC;CACvD,OAAO,OAAO,cAAc,YAAY,UAAU,SAAS,KAAK,UAAU,UAAU,MAAM,YAAY,KAAA;AACxG;AAEA,SAAgB,WAAW,SAAsC;CAC/D,IAAI,CAAC,WAAW,OAAO,YAAY,UAAU,OAAO,KAAA;CACpD,MAAM,MAAM;CACZ,MAAM,MAAM,IAAI,MAAM,OAAO,IAAI,QAAQ;CACzC,OAAO,OAAO,QAAQ,WAAW,MAAM,KAAA;AACzC;AAEA,SAAgB,YAAY,MAAsB,OAAgC;CAChF,IAAI,KAAK,SAAS,UAAU,OAAO,MAAM,SAAS;CAClD,OAAO,MAAM,SAAS,aAAa,KAAK,cAAc,MAAM;AAC9D;AAEA,SAAgB,SAAS,OAA+B;CACtD,OAAO,MAAM,SAAS,WAAW,WAAW,WAAW,MAAM;AAC/D;AAEA,SAAgB,YAAY,QAAoC;CAC9D,OAAO,gBAAgB,MAAM;AAC/B"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AiFeatureScope, CHAT_EVENTS_SLOT, DreamPlan, InjectedMemoryMessage, MEMORY_RPC_CHANNEL, MemoryMutationOptions, MemoryPersistedState, MemoryQuery, MemoryRecord, MemoryService, MemorySettings, MemoryStatus, NewMemoryRecord, PreStepDecision, defaultSettings, projectIdFromCwd } from "./contracts.js";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
//#region src/store.d.ts
|
|
4
|
+
interface MemoryStore {
|
|
5
|
+
load(): MemoryPersistedState;
|
|
6
|
+
save(state: MemoryPersistedState): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/service.d.ts
|
|
10
|
+
interface MemoryRuntimeOptions {
|
|
11
|
+
store: MemoryStore;
|
|
12
|
+
now?: () => number;
|
|
13
|
+
id?: () => string;
|
|
14
|
+
activateAi?: () => AiFeatureScope | undefined;
|
|
15
|
+
createInjectMessage?: (payload: InjectedMemoryMessage) => unknown;
|
|
16
|
+
}
|
|
17
|
+
declare class MemoryRuntime implements MemoryService {
|
|
18
|
+
private readonly options;
|
|
19
|
+
private live;
|
|
20
|
+
private generation;
|
|
21
|
+
private disposed;
|
|
22
|
+
private storageFailed;
|
|
23
|
+
private pending;
|
|
24
|
+
private ai?;
|
|
25
|
+
private unregisterPurpose?;
|
|
26
|
+
private readonly jobs;
|
|
27
|
+
private readonly now;
|
|
28
|
+
private readonly customId?;
|
|
29
|
+
constructor(options: MemoryRuntimeOptions);
|
|
30
|
+
get pluginActive(): boolean;
|
|
31
|
+
status(sessionId?: string, projectId?: string): MemoryStatus;
|
|
32
|
+
/** Wait for durable state writes, never for model generation. */
|
|
33
|
+
readStatus(sessionId?: string, projectId?: string): Promise<MemoryStatus>;
|
|
34
|
+
dispose(): Promise<void>;
|
|
35
|
+
updateSettings(next: Omit<MemorySettings, 'revision'>, expectedRevision: number): Promise<MemorySettings>;
|
|
36
|
+
list(query: MemoryQuery): Promise<MemoryRecord[]>;
|
|
37
|
+
recall(query: MemoryQuery): Promise<MemoryRecord[]>;
|
|
38
|
+
create(record: NewMemoryRecord, options?: MemoryMutationOptions): Promise<MemoryRecord>;
|
|
39
|
+
update(id: string, patch: Partial<Pick<MemoryRecord, 'title' | 'content' | 'tags' | 'exceptions' | 'status' | 'expiresAt'>>, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>;
|
|
40
|
+
remove(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<void>;
|
|
41
|
+
accept(id: string, expectedRevision: number): Promise<MemoryRecord>;
|
|
42
|
+
reject(id: string, expectedRevision: number): Promise<MemoryRecord>;
|
|
43
|
+
revoke(id: string, expectedRevision: number): Promise<MemoryRecord>;
|
|
44
|
+
promoteToGlobal(id: string, expectedRevision: number, options?: MemoryMutationOptions): Promise<MemoryRecord>;
|
|
45
|
+
handlePreStep(input: {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
session?: unknown;
|
|
48
|
+
signal: AbortSignal;
|
|
49
|
+
next: () => Promise<PreStepDecision>;
|
|
50
|
+
}): Promise<PreStepDecision>;
|
|
51
|
+
previewDream(sessionId: string, projectId: string | undefined, trigger?: 'manual' | 'idle'): Promise<DreamPlan>;
|
|
52
|
+
runIdleDream(sessionId: string, projectId: string | undefined, trigger?: 'manual' | 'idle'): Promise<DreamPlan>;
|
|
53
|
+
get dreamLastAttemptAt(): number | undefined;
|
|
54
|
+
dreamMaterialCount(): number;
|
|
55
|
+
applyDream(planId: string, expectedRevision: number): Promise<DreamPlan>;
|
|
56
|
+
cancelDream(planId: string, expectedRevision: number): Promise<DreamPlan>;
|
|
57
|
+
createManualRecord(input: {
|
|
58
|
+
sessionId: string;
|
|
59
|
+
projectId?: string;
|
|
60
|
+
explicitGlobal: boolean;
|
|
61
|
+
title: string;
|
|
62
|
+
content: string;
|
|
63
|
+
kind: NewMemoryRecord['kind'];
|
|
64
|
+
tags?: string[];
|
|
65
|
+
exceptions?: string[];
|
|
66
|
+
evidence?: NewMemoryRecord['evidence'];
|
|
67
|
+
expiresAt?: number;
|
|
68
|
+
}): Promise<MemoryRecord>;
|
|
69
|
+
abortDreams(): void;
|
|
70
|
+
hasActiveDream(sessionId?: string): boolean;
|
|
71
|
+
private updateIn;
|
|
72
|
+
private mintId;
|
|
73
|
+
private idTaken;
|
|
74
|
+
private tombstoned;
|
|
75
|
+
private tombstonedIn;
|
|
76
|
+
private requireIn;
|
|
77
|
+
private requireDreamIn;
|
|
78
|
+
private markDream;
|
|
79
|
+
private currentDream;
|
|
80
|
+
private markDreamQuietly;
|
|
81
|
+
private stampDreamAttempt;
|
|
82
|
+
private recordFailedDreamAttempt;
|
|
83
|
+
private staleDreamsTouching;
|
|
84
|
+
private visibleInSession;
|
|
85
|
+
private canInject;
|
|
86
|
+
private isDreamCurrent;
|
|
87
|
+
private requireAi;
|
|
88
|
+
private syncAi;
|
|
89
|
+
private detachAi;
|
|
90
|
+
private assertOpen;
|
|
91
|
+
private snapshot;
|
|
92
|
+
private commit;
|
|
93
|
+
private assertMutationCurrent;
|
|
94
|
+
private persistProposed;
|
|
95
|
+
private serialize;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/index.d.ts
|
|
99
|
+
declare const name = "@klarkxy/dsh-memory";
|
|
100
|
+
declare const inject: readonly ["storageDomain", "connection", "webServer", "aiServices", "sessions"];
|
|
101
|
+
declare module '@deepseek-ai/cordis' {
|
|
102
|
+
interface Context {
|
|
103
|
+
aiMemory: MemoryRuntime;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
declare function apply(ctx: Context): Promise<void>;
|
|
107
|
+
declare function createPluginUserMessage(payload: InjectedMemoryMessage): unknown;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { CHAT_EVENTS_SLOT, MEMORY_RPC_CHANNEL, MemoryRuntime, apply, createPluginUserMessage, defaultSettings, inject, name, projectIdFromCwd };
|
|
110
|
+
//# sourceMappingURL=index.d.ts.map
|