dsh-mnemon 0.3.3 → 0.3.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.
@@ -36,6 +36,7 @@ export declare class MnemonClient {
36
36
  content?: string;
37
37
  old_text?: string;
38
38
  importance?: RuntimeMemoryImportance;
39
+ branches?: string[];
39
40
  }): Promise<RuntimeMemoryMutationResult>;
40
41
  documents(): Promise<DocumentSnapshot>;
41
42
  document(id: string): Promise<DocumentView>;
@@ -333,6 +333,10 @@ export declare const zh: {
333
333
  'runtime.importance.critical': string;
334
334
  'runtime.importance.normal': string;
335
335
  'runtime.importance.low': string;
336
+ 'runtime.branches': string;
337
+ 'runtime.branchesPlaceholder': string;
338
+ 'runtime.branchesHint': string;
339
+ 'runtime.branchBadge': string;
336
340
  'runtime.empty': string;
337
341
  'runtime.editContent': string;
338
342
  'runtime.editAction': string;
@@ -706,6 +710,13 @@ export declare const zh: {
706
710
  'config.customHintShort': string;
707
711
  'config.customSelected': string;
708
712
  'config.globalScopeHint': string;
713
+ 'config.runtimeUserScopeTitle': string;
714
+ 'config.runtimeUserScopeDescription': string;
715
+ 'config.runtimeUserScopeAria': string;
716
+ 'config.runtimeUserScopeStorage': string;
717
+ 'config.runtimeUserScopeStorageHint': string;
718
+ 'config.runtimeUserScopeGlobal': string;
719
+ 'config.runtimeUserScopeGlobalHint': string;
709
720
  'config.topologyTitle': string;
710
721
  'config.topologyDescription': string;
711
722
  'config.topologyLoading': string;
@@ -826,6 +837,7 @@ export declare const zh: {
826
837
  'config.customDirectoryHint': string;
827
838
  'config.customPlaceholder': string;
828
839
  'config.invalidScope': string;
840
+ 'config.invalidRuntimeUserScope': string;
829
841
  'config.customRequired': string;
830
842
  'config.customAbsolute': string;
831
843
  'config.saveFailed': string;
@@ -1228,6 +1240,10 @@ export declare const en: {
1228
1240
  'runtime.importance.critical': string;
1229
1241
  'runtime.importance.normal': string;
1230
1242
  'runtime.importance.low': string;
1243
+ 'runtime.branches': string;
1244
+ 'runtime.branchesPlaceholder': string;
1245
+ 'runtime.branchesHint': string;
1246
+ 'runtime.branchBadge': string;
1231
1247
  'runtime.empty': string;
1232
1248
  'runtime.editContent': string;
1233
1249
  'runtime.editAction': string;
@@ -1601,6 +1617,13 @@ export declare const en: {
1601
1617
  'config.customHintShort': string;
1602
1618
  'config.customSelected': string;
1603
1619
  'config.globalScopeHint': string;
1620
+ 'config.runtimeUserScopeTitle': string;
1621
+ 'config.runtimeUserScopeDescription': string;
1622
+ 'config.runtimeUserScopeAria': string;
1623
+ 'config.runtimeUserScopeStorage': string;
1624
+ 'config.runtimeUserScopeStorageHint': string;
1625
+ 'config.runtimeUserScopeGlobal': string;
1626
+ 'config.runtimeUserScopeGlobalHint': string;
1604
1627
  'config.topologyTitle': string;
1605
1628
  'config.topologyDescription': string;
1606
1629
  'config.topologyLoading': string;
@@ -1721,6 +1744,7 @@ export declare const en: {
1721
1744
  'config.customDirectoryHint': string;
1722
1745
  'config.customPlaceholder': string;
1723
1746
  'config.invalidScope': string;
1747
+ 'config.invalidRuntimeUserScope': string;
1724
1748
  'config.customRequired': string;
1725
1749
  'config.customAbsolute': string;
1726
1750
  'config.saveFailed': string;
@@ -7,4 +7,9 @@ export declare const DEFAULT_RECALL_HIGH_SCORE_THRESHOLD = 0.6;
7
7
  export declare const DEFAULT_RECALL_CANDIDATE_MULTIPLIER = 3;
8
8
  export declare const DEFAULT_RECALL_MAX_MEDIUM_RESULTS = 4;
9
9
  export declare const DEFAULT_RECALL_MAX_UNKNOWN_RESULTS = 2;
10
+ export declare const DEFAULT_RUNTIME_MEMORY_LIMIT_BYTES: number;
11
+ export declare const DEFAULT_RUNTIME_USER_LIMIT_BYTES: number;
12
+ export declare const DEFAULT_RUNTIME_MAINTENANCE_MAX_TOKENS = 8192;
13
+ export declare const MAX_RUNTIME_MEMORY_LIMIT_BYTES: number;
14
+ export declare const MAX_RUNTIME_MAINTENANCE_MAX_TOKENS = 1000000;
10
15
  export { DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL } from './shared/contracts.ts';
@@ -1,6 +1,6 @@
1
1
  import z from 'schemastery';
2
2
  import type { Config as SharedConfig, CustomPackConfig as SharedCustomPackConfig, InteractionConfig as SharedInteractionConfig, ResolvedConfig as SharedResolvedConfig, ResolvedInteractionConfig as SharedResolvedInteractionConfig } from './shared/contracts.ts';
3
- export { DEFAULT_IDLE_REVIEW_MS, DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_RECALL_CANDIDATE_MULTIPLIER, DEFAULT_RECALL_HIGH_SCORE_THRESHOLD, DEFAULT_RECALL_LIMIT, DEFAULT_RECALL_LOW_SCORE_THRESHOLD, DEFAULT_RECALL_MAX_MEDIUM_RESULTS, DEFAULT_RECALL_MAX_UNKNOWN_RESULTS, DEFAULT_RECALL_QUALITY_POLICY, DEFAULT_TIMEOUT_MS, } from './config-values.ts';
3
+ export { DEFAULT_IDLE_REVIEW_MS, DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_RECALL_CANDIDATE_MULTIPLIER, DEFAULT_RECALL_HIGH_SCORE_THRESHOLD, DEFAULT_RECALL_LIMIT, DEFAULT_RECALL_LOW_SCORE_THRESHOLD, DEFAULT_RECALL_MAX_MEDIUM_RESULTS, DEFAULT_RECALL_MAX_UNKNOWN_RESULTS, DEFAULT_RECALL_QUALITY_POLICY, DEFAULT_RUNTIME_MAINTENANCE_MAX_TOKENS, DEFAULT_RUNTIME_MEMORY_LIMIT_BYTES, DEFAULT_RUNTIME_USER_LIMIT_BYTES, DEFAULT_TIMEOUT_MS, MAX_RUNTIME_MAINTENANCE_MAX_TOKENS, MAX_RUNTIME_MEMORY_LIMIT_BYTES, } from './config-values.ts';
4
4
  export type Config = SharedConfig;
5
5
  export type CustomPackConfig = SharedCustomPackConfig;
6
6
  export type InteractionConfig = SharedInteractionConfig;
@@ -151,6 +151,14 @@ export interface HostAgent {
151
151
  agentPreset?: string;
152
152
  };
153
153
  events: readonly HostSessionEvent[];
154
+ /**
155
+ * Model-visible event sequences, in order. Optional because not every host
156
+ * publishes a surface projection; when absent, callers fall back to
157
+ * session-scoped state.
158
+ */
159
+ surface?: {
160
+ readonly nodes: readonly number[];
161
+ };
154
162
  };
155
163
  ctx: HostAgentContext;
156
164
  followup(message: HostUserMessage): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Resolve the current git branch of a workspace root. Returns undefined when
3
+ * the directory is not a git working tree, HEAD is detached, or the probe
4
+ * fails or times out, so callers fall back to the unfiltered view.
5
+ */
6
+ export declare function resolveGitBranch(cwd?: string): string | undefined;
@@ -1,4 +1,4 @@
1
- import { MemoryTurnViewManager } from '../packages/kernel/src/index.ts';
1
+ import { MemoryTurnViewManager, type MemorySource } from '../packages/kernel/src/index.ts';
2
2
  import type { DocumentManager } from './documents.ts';
3
3
  import type { MemoryKernel } from './memory-system/kernel.ts';
4
4
  import type { RuntimeMemoryController } from './runtime-memory.ts';
@@ -10,6 +10,12 @@ export interface DefaultMemorySources {
10
10
  }
11
11
  /** Compatibility name for the v0.3 pre-release API. */
12
12
  export type DefaultMemoryViewSources = DefaultMemorySources;
13
- export declare function createDefaultMemoryTurnViewManager(kernel: MemoryKernel, sources: DefaultMemorySources): MemoryTurnViewManager;
13
+ export type BranchResolver = (cwd?: string) => string | undefined;
14
+ export interface DefaultMemoryTurnViewManagerOptions {
15
+ /** Override the git branch probe used for runtime branch scoping. Defaults to resolveGitBranch. */
16
+ resolveBranch?: BranchResolver;
17
+ }
18
+ export declare function createRuntimeMemorySource(runtimeMemory: RuntimeMemoryController, resolveBranch?: BranchResolver): MemorySource;
19
+ export declare function createDefaultMemoryTurnViewManager(kernel: MemoryKernel, sources: DefaultMemorySources, options?: DefaultMemoryTurnViewManagerOptions): MemoryTurnViewManager;
14
20
  /** Compatibility name for the v0.3 pre-release API. */
15
21
  export declare const createDefaultMemoryViewManager: typeof createDefaultMemoryTurnViewManager;
@@ -14,7 +14,8 @@ export declare class MnemonPackManager {
14
14
  private readonly afterImport;
15
15
  private readonly now;
16
16
  private readonly root;
17
- constructor(runner: MnemonRunner, config: Pick<ResolvedConfig, 'storageScope'>, afterImport?: (components: MnemonPackComponent[]) => void, now?: () => Date);
17
+ private readonly runtimeLimits;
18
+ constructor(runner: MnemonRunner, config: Pick<ResolvedConfig, 'storageScope' | 'runtimeMemory'>, afterImport?: (components: MnemonPackComponent[]) => void, now?: () => Date);
18
19
  target(): {
19
20
  root: string;
20
21
  scope: ResolvedConfig['storageScope'];
@@ -5,10 +5,11 @@ import type { RuntimeMemoryAction, RuntimeMemoryCompactedEntry, RuntimeMemoryEnt
5
5
  export type { RuntimeMemoryAction, RuntimeMemoryCompactedEntry, RuntimeMemoryEntry, RuntimeMemoryImportance, RuntimeMemoryMutation, RuntimeMemoryMutationResult, RuntimeMemorySnapshot, RuntimeMemoryTarget, RuntimeMemoryTargetView, RuntimeMemoryUsage, } from './shared/contracts.ts';
6
6
  export declare const RUNTIME_MEMORY_VERSION = 1;
7
7
  export declare const RUNTIME_ENTRY_DELIMITER = "\n\u00A7\n";
8
- export declare const RUNTIME_MEMORY_LIMITS: {
8
+ export interface RuntimeMemoryLimits {
9
9
  readonly memory: number;
10
10
  readonly user: number;
11
- };
11
+ }
12
+ export declare const RUNTIME_MEMORY_LIMITS: RuntimeMemoryLimits;
12
13
  export declare const RUNTIME_MEMORY_PROTOCOL: string;
13
14
  export interface RuntimeMemoryContextProjection {
14
15
  revision: string;
@@ -37,6 +38,10 @@ export declare class RuntimeMemoryCapacityError extends Error {
37
38
  export declare class RuntimeMemoryConflictError extends Error {
38
39
  constructor();
39
40
  }
41
+ export declare const RUNTIME_BRANCH_NAME_MAX = 128;
42
+ export declare const RUNTIME_BRANCHES_PER_ENTRY_MAX = 16;
43
+ /** Validate a model-supplied branch scope. Returns the normalized list; an empty list means "no scope". */
44
+ export declare function normalizeRuntimeBranches(value: unknown, field?: string): string[];
40
45
  /**
41
46
  * Single authority for hot memory. JSON is the durable source of truth;
42
47
  * Markdown files are deterministic projections consumed by prompt assembly.
@@ -46,15 +51,26 @@ export declare class RuntimeMemoryController {
46
51
  private readonly recordCommit?;
47
52
  readonly directory: string;
48
53
  readonly sourcePath: string;
54
+ readonly userSourcePath: string;
49
55
  readonly memoryPath: string;
50
56
  readonly userPath: string;
51
57
  readonly lockPath: string;
58
+ readonly limits: RuntimeMemoryLimits;
52
59
  private queue;
53
- constructor(runner: Pick<MnemonRunner, 'effectiveDataDir'>, now?: () => Date, recordCommit?: AuthorityCommitRecorder | undefined);
60
+ private readonly localUserPath;
61
+ private readonly userController;
62
+ constructor(runner: Pick<MnemonRunner, 'effectiveDataDir'>, now?: () => Date, recordCommit?: AuthorityCommitRecorder | undefined, limits?: RuntimeMemoryLimits, userRunner?: Pick<MnemonRunner, 'effectiveDataDir'>);
54
63
  snapshot(): RuntimeMemorySnapshot;
55
- contextText(): string;
56
- /** Read the exact Runtime revision and its prompt projection under one lock. */
57
- contextProjection(): RuntimeMemoryContextProjection;
64
+ contextText(branch?: string): string;
65
+ /**
66
+ * Read the exact Runtime revision and its prompt projection from each
67
+ * configured authority root.
68
+ * When a git branch is supplied, target=memory entries scoped to other
69
+ * branches are hidden from the projection; the on-disk Markdown files and
70
+ * the source JSON always remain complete.
71
+ */
72
+ contextProjection(branch?: string): RuntimeMemoryContextProjection;
73
+ private localContextProjection;
58
74
  mutate(request: RuntimeMemoryMutation): Promise<RuntimeMemoryMutationResult>;
59
75
  /** Resolve exactly which committed entries survive a blocked mutation and are safe to compact. */
60
76
  planMaintenance(request: RuntimeMemoryMutation): Promise<RuntimeMemoryMaintenancePlan>;
@@ -104,6 +104,19 @@ export interface RecallQualityConfig {
104
104
  /** Maximum unknown-scale or unscored rows admitted by the strict policy. */
105
105
  maxUnknownResults?: number;
106
106
  }
107
+ export interface RuntimeMemoryConfig {
108
+ /** Maximum UTF-8 bytes projected into MEMORY.md. */
109
+ memoryLimitBytes?: number;
110
+ /** Maximum UTF-8 bytes projected into USER.md. */
111
+ userLimitBytes?: number;
112
+ /** Completion-token budget for Runtime migration and compaction workers. */
113
+ maintenanceMaxTokens?: number;
114
+ }
115
+ export interface ResolvedRuntimeMemoryConfig {
116
+ memoryLimitBytes: number;
117
+ userLimitBytes: number;
118
+ maintenanceMaxTokens: number;
119
+ }
107
120
  export interface ResolvedRecallQualityConfig {
108
121
  policy: string;
109
122
  lowScoreThreshold: number;
@@ -114,6 +127,8 @@ export interface ResolvedRecallQualityConfig {
114
127
  }
115
128
  export interface Config {
116
129
  storageScope?: StorageScopeKind;
130
+ /** Whether USER.md follows the selected storage root or stays in the global root. */
131
+ runtimeUserScope?: 'storage' | 'global';
117
132
  cliPath?: string;
118
133
  dataDir?: string;
119
134
  customPackId?: string;
@@ -121,6 +136,7 @@ export interface Config {
121
136
  store?: string;
122
137
  timeoutMs?: number;
123
138
  defaultRecallLimit?: number;
139
+ runtimeMemory?: RuntimeMemoryConfig;
124
140
  /** Optional DSH-owned overrides injected into every Mnemon CLI process. */
125
141
  embedding?: MnemonEmbeddingConfig;
126
142
  memoryTopology?: MemoryTopologyConfig;
@@ -202,11 +218,13 @@ export interface InteractionConfig {
202
218
  }
203
219
  export interface ResolvedConfig {
204
220
  storageScope: StorageScopeKind;
221
+ runtimeUserScope: 'storage' | 'global';
205
222
  cliPath?: string;
206
223
  dataDir?: string;
207
224
  store?: string;
208
225
  timeoutMs: number;
209
226
  defaultRecallLimit: number;
227
+ runtimeMemory: ResolvedRuntimeMemoryConfig;
210
228
  embedding: ResolvedMnemonEmbeddingConfig;
211
229
  memoryTopology: ResolvedMemoryTopologyConfig;
212
230
  recallQuality: ResolvedRecallQualityConfig;
@@ -683,6 +701,8 @@ export interface RuntimeMemoryEntry {
683
701
  updated_at: string;
684
702
  target: RuntimeMemoryTarget;
685
703
  importance: RuntimeMemoryImportance;
704
+ /** Optional git branch names that limit where this entry is projected. Absent means every branch. */
705
+ branches?: string[];
686
706
  }
687
707
  export interface RuntimeMemoryUsage {
688
708
  used: number;
@@ -704,6 +724,8 @@ export interface RuntimeMemorySnapshot {
704
724
  export interface RuntimeMemoryCompactedEntry {
705
725
  content: string;
706
726
  importance: RuntimeMemoryImportance;
727
+ /** Branch scope carried through compaction; absent means the entry is visible on every branch. */
728
+ branches?: string[];
707
729
  }
708
730
  export interface RuntimeMemoryMutation {
709
731
  action: RuntimeMemoryAction;
@@ -711,6 +733,8 @@ export interface RuntimeMemoryMutation {
711
733
  content?: string;
712
734
  oldText?: string;
713
735
  importance?: RuntimeMemoryImportance;
736
+ /** Git branch names limiting where a target=memory entry is projected. Absent keeps the current scope on replace; an empty list clears it. */
737
+ branches?: string[];
714
738
  }
715
739
  export type RuntimeMemoryMutationResult = {
716
740
  success: true;
@@ -66,6 +66,7 @@ export declare class MnemonSubagentCoordinator {
66
66
  private readonly documents?;
67
67
  private readonly resultRuntime?;
68
68
  private readonly taskAgentModelResolver?;
69
+ private readonly runtimeMaintenanceMaxTokensResolver?;
69
70
  private readonly counters;
70
71
  private runtimeQueue;
71
72
  private documentQueue;
@@ -73,7 +74,7 @@ export declare class MnemonSubagentCoordinator {
73
74
  constructor(subagents: HostSubagentsService, runtimeMemoryOrSource?: (RuntimeMemoryController | AgentRuntimeSource) | undefined, documents?: DocumentManager | undefined, resultRuntime?: HostResultToolRuntime | undefined, taskAgentModelResolver?: (() => {
74
75
  provider: string;
75
76
  model: string;
76
- } | undefined) | undefined);
77
+ } | undefined) | undefined, runtimeMaintenanceMaxTokensResolver?: (() => number) | undefined);
77
78
  snapshot(): SubagentCounters;
78
79
  documentsSnapshot(parent: HostAgent): import("./documents.ts").DocumentSnapshot;
79
80
  documentGet(parent: HostAgent, id: string): DocumentView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mnemon",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Composable three-tier memory control plane for DeepSeek Harness: persistent runtime context, searchable project documents, pluggable long-term memory, guarded strategies, WebUI, and headless tools.",
5
5
  "keywords": [
6
6
  "deepseek-harness",