dsh-mnemon 0.3.4 → 0.3.6
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 +3 -3
- package/README.zh-CN.md +3 -3
- package/lib/client.js +165 -62
- package/lib/index.js +387 -155
- package/lib/kernel.js +47 -0
- package/lib/types/packages/kernel/src/view.d.ts +11 -0
- package/lib/types/src/agent-memory-turn.d.ts +42 -0
- package/lib/types/src/client/MnemonTurnTail.d.ts +3 -2
- package/lib/types/src/client/MnemonView.d.ts +1 -1
- package/lib/types/src/client/dsh-compat.d.ts +34 -3
- package/lib/types/src/client/locales.d.ts +18 -0
- package/lib/types/src/client/subagent-token-usage.d.ts +3 -4
- package/lib/types/src/config-values.d.ts +1 -1
- package/lib/types/src/config.d.ts +1 -1
- package/lib/types/src/contracts.d.ts +28 -6
- package/lib/types/src/guidance.d.ts +1 -0
- package/lib/types/src/lifecycle.d.ts +4 -0
- package/lib/types/src/live-runtime.d.ts +1 -1
- package/lib/types/src/rpc.d.ts +7 -7
- package/lib/types/src/shared/contracts.d.ts +18 -1
- package/lib/types/src/subagent.d.ts +2 -2
- package/lib/types/src/tools.d.ts +1 -1
- package/package.json +16 -5
package/lib/kernel.js
CHANGED
|
@@ -837,6 +837,7 @@ var MemoryTurnViewManager = class {
|
|
|
837
837
|
sourceGeneration = 0;
|
|
838
838
|
views = /* @__PURE__ */ new Map();
|
|
839
839
|
turns = /* @__PURE__ */ new Map();
|
|
840
|
+
retainedViews = /* @__PURE__ */ new Map();
|
|
840
841
|
pendingReceipts = /* @__PURE__ */ new Map();
|
|
841
842
|
current;
|
|
842
843
|
currentByScope = /* @__PURE__ */ new Map();
|
|
@@ -922,6 +923,17 @@ var MemoryTurnViewManager = class {
|
|
|
922
923
|
return existing;
|
|
923
924
|
}
|
|
924
925
|
const view = await this.reconcile(scope);
|
|
926
|
+
return this.pinTurn(id, scope, view.id);
|
|
927
|
+
}
|
|
928
|
+
/** Pin an already-authorized View without re-snapshotting a newer Source. */
|
|
929
|
+
pinTurn(turnId, scope, viewId) {
|
|
930
|
+
const id = text(turnId, "memory turn id", 300);
|
|
931
|
+
const view = this.requireStoredView(viewId).view;
|
|
932
|
+
const existing = this.turns.get(id);
|
|
933
|
+
if (existing !== void 0) {
|
|
934
|
+
if (!sameScope(existing.scope, scope) || existing.viewId !== view.id) throw new Error(`memory turn authority changed while pinned: ${id}`);
|
|
935
|
+
return existing;
|
|
936
|
+
}
|
|
925
937
|
const context = deepFreeze({
|
|
926
938
|
turnId: id,
|
|
927
939
|
viewId: view.id,
|
|
@@ -932,6 +944,20 @@ var MemoryTurnViewManager = class {
|
|
|
932
944
|
this.turns.set(id, context);
|
|
933
945
|
return context;
|
|
934
946
|
}
|
|
947
|
+
/** Keep a delegated View available independently of the originating turn. */
|
|
948
|
+
retainView(viewId) {
|
|
949
|
+
const id = this.requireStoredView(viewId).view.id;
|
|
950
|
+
this.retainedViews.set(id, (this.retainedViews.get(id) ?? 0) + 1);
|
|
951
|
+
let retained = true;
|
|
952
|
+
return () => {
|
|
953
|
+
if (!retained) return;
|
|
954
|
+
retained = false;
|
|
955
|
+
const count = this.retainedViews.get(id) ?? 0;
|
|
956
|
+
if (count > 1) this.retainedViews.set(id, count - 1);
|
|
957
|
+
else this.retainedViews.delete(id);
|
|
958
|
+
this.collect();
|
|
959
|
+
};
|
|
960
|
+
}
|
|
935
961
|
turn(turnId) {
|
|
936
962
|
return this.turns.get(turnId);
|
|
937
963
|
}
|
|
@@ -939,6 +965,26 @@ var MemoryTurnViewManager = class {
|
|
|
939
965
|
const id = text(agentId, "memory agent id", 300);
|
|
940
966
|
return [...this.turns.values()].findLast((turn) => turn.scope.agentId === id);
|
|
941
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* Latest reconciled View for inspection, not execution authority. A child
|
|
970
|
+
* must retain its delegated View and pin its own turn instead of inheriting
|
|
971
|
+
* whatever its parent's later turns happen to publish.
|
|
972
|
+
*/
|
|
973
|
+
lastViewForAgent(agentId) {
|
|
974
|
+
const id = text(agentId, "memory agent id", 300);
|
|
975
|
+
let match;
|
|
976
|
+
for (const [key, view] of this.currentByScope) {
|
|
977
|
+
let owner;
|
|
978
|
+
try {
|
|
979
|
+
owner = JSON.parse(key).agentId;
|
|
980
|
+
} catch {
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (owner !== id) continue;
|
|
984
|
+
if (match === void 0 || view.createdAt > match.createdAt) match = view;
|
|
985
|
+
}
|
|
986
|
+
return match;
|
|
987
|
+
}
|
|
942
988
|
endTurn(turnId) {
|
|
943
989
|
const deleted = this.turns.delete(turnId);
|
|
944
990
|
if (deleted) this.collect();
|
|
@@ -1113,6 +1159,7 @@ var MemoryTurnViewManager = class {
|
|
|
1113
1159
|
collect() {
|
|
1114
1160
|
if (this.views.size <= this.maxViews) return;
|
|
1115
1161
|
const pinned = new Set([...this.turns.values()].map((turn) => turn.viewId));
|
|
1162
|
+
for (const id of this.retainedViews.keys()) pinned.add(id);
|
|
1116
1163
|
if (this.current !== void 0) pinned.add(this.current.id);
|
|
1117
1164
|
for (const id of this.views.keys()) {
|
|
1118
1165
|
if (this.views.size <= this.maxViews) break;
|
|
@@ -38,6 +38,7 @@ export declare class MemoryTurnViewManager {
|
|
|
38
38
|
private sourceGeneration;
|
|
39
39
|
private readonly views;
|
|
40
40
|
private readonly turns;
|
|
41
|
+
private readonly retainedViews;
|
|
41
42
|
private readonly pendingReceipts;
|
|
42
43
|
private current;
|
|
43
44
|
private readonly currentByScope;
|
|
@@ -59,8 +60,18 @@ export declare class MemoryTurnViewManager {
|
|
|
59
60
|
pendingReceiptCount(): number;
|
|
60
61
|
apply(receipt: MemoryReceipt): boolean;
|
|
61
62
|
beginTurn(turnId: string, scope: MemoryOperationScope): Promise<MemoryTurnContext>;
|
|
63
|
+
/** Pin an already-authorized View without re-snapshotting a newer Source. */
|
|
64
|
+
pinTurn(turnId: string, scope: MemoryOperationScope, viewId: string): MemoryTurnContext;
|
|
65
|
+
/** Keep a delegated View available independently of the originating turn. */
|
|
66
|
+
retainView(viewId: string): () => void;
|
|
62
67
|
turn(turnId: string): MemoryTurnContext | undefined;
|
|
63
68
|
activeTurn(agentId: string): MemoryTurnContext | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Latest reconciled View for inspection, not execution authority. A child
|
|
71
|
+
* must retain its delegated View and pin its own turn instead of inheriting
|
|
72
|
+
* whatever its parent's later turns happen to publish.
|
|
73
|
+
*/
|
|
74
|
+
lastViewForAgent(agentId: string): MemoryTurnView | undefined;
|
|
64
75
|
endTurn(turnId: string): boolean;
|
|
65
76
|
wake(viewId: string): MemoryWake;
|
|
66
77
|
/** Compile and publish a candidate. On failure, preserve the last valid scoped View. */
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MemoryOperationScope, MemoryTurnContext } from '../packages/contracts/src/index.ts';
|
|
2
|
+
import type { MemoryTurnViewManager } from '../packages/kernel/src/index.ts';
|
|
3
|
+
import type { HostAgent } from './contracts.ts';
|
|
4
|
+
import type { MnemonAgentRuntimeSource, MnemonRuntimeGraph } from './live-runtime.ts';
|
|
5
|
+
/** Host-owned authority captured before a child activation starts executing. */
|
|
6
|
+
export interface DelegatedMemoryView {
|
|
7
|
+
readonly graph: MnemonRuntimeGraph;
|
|
8
|
+
readonly scope: MemoryOperationScope;
|
|
9
|
+
readonly viewId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PinnedAgentMemoryTurn {
|
|
12
|
+
readonly turn: number;
|
|
13
|
+
readonly graph: MnemonRuntimeGraph;
|
|
14
|
+
readonly manager: MemoryTurnViewManager;
|
|
15
|
+
readonly context: MemoryTurnContext;
|
|
16
|
+
readonly releaseRuntime?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function agentMemoryScope(agent: HostAgent, graph: MnemonRuntimeGraph): MemoryOperationScope;
|
|
19
|
+
/** The durable log, not a parent session id, identifies the executing turn. */
|
|
20
|
+
export declare function openAgentTurn(agent: HostAgent): number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* One Agent owns each turn pin. A child additionally retains its delegation
|
|
23
|
+
* across parent completion, collection, and runtime swaps until it is disposed.
|
|
24
|
+
*/
|
|
25
|
+
export declare class AgentMemoryTurn {
|
|
26
|
+
private readonly agent;
|
|
27
|
+
private readonly runtime;
|
|
28
|
+
private readonly delegation?;
|
|
29
|
+
private pinned;
|
|
30
|
+
private pending;
|
|
31
|
+
private generation;
|
|
32
|
+
private closed;
|
|
33
|
+
private readonly releaseDelegation;
|
|
34
|
+
constructor(agent: HostAgent, runtime: Pick<MnemonAgentRuntimeSource, 'forAgent' | 'bindAgentRuntime'>, delegation?: DelegatedMemoryView | undefined);
|
|
35
|
+
get current(): PinnedAgentMemoryTurn | undefined;
|
|
36
|
+
/** Capture now; descendants must not resolve a later parent turn on demand. */
|
|
37
|
+
delegate(): DelegatedMemoryView;
|
|
38
|
+
begin(turn: number, signal?: AbortSignal): Promise<void>;
|
|
39
|
+
end(turn?: number): void;
|
|
40
|
+
dispose(): void;
|
|
41
|
+
private pin;
|
|
42
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ClientConnectionHandle } from '../shared/contracts.ts';
|
|
2
|
-
import type { TurnTailOwnerProps } from '@deepseek-ai/dsh-client-ui-conversation/client';
|
|
3
2
|
import { type MnemonAnchorPage } from './anchor.ts';
|
|
4
3
|
import type { MnemonKey } from './locales.ts';
|
|
5
4
|
export interface MnemonTurnTailProps {
|
|
@@ -15,6 +14,8 @@ export interface MnemonTurnTailProps {
|
|
|
15
14
|
/** Route a settled tool name to the workbench page that explains its effect. */
|
|
16
15
|
export declare function memoryPageForTool(name: string): MnemonAnchorPage;
|
|
17
16
|
/** Whether this entry renders for the owner; chain selectors decline quietly. */
|
|
18
|
-
export declare function selectMnemonTurnTail(owner:
|
|
17
|
+
export declare function selectMnemonTurnTail(owner: {
|
|
18
|
+
turn: unknown;
|
|
19
|
+
}): Record<string, never> | null;
|
|
19
20
|
/** One-line memory-activity bar under a completed turn; hides when the turn touched no memory. */
|
|
20
21
|
export declare const MnemonTurnTail: import("react").NamedExoticComponent<MnemonTurnTailProps>;
|
|
@@ -6,15 +6,46 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client';
|
|
8
8
|
import type { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client';
|
|
9
|
-
import type {
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
10
10
|
import type { MnemonKey } from './locales.ts';
|
|
11
11
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
12
12
|
interface LocaleNamespaceMap {
|
|
13
13
|
mnemon: MnemonKey;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
export interface MnemonSessionSummary {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
origin?: string;
|
|
19
|
+
projectionValues?: Readonly<Record<string, unknown>>;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface MnemonSessionListState {
|
|
23
|
+
current?: string;
|
|
24
|
+
byId: Record<string, MnemonSessionSummary>;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface MnemonWorkspaceSummary {
|
|
28
|
+
workspaceId: unknown;
|
|
29
|
+
title: string;
|
|
30
|
+
path: string;
|
|
31
|
+
}
|
|
32
|
+
export interface MnemonWorkspaceListState {
|
|
33
|
+
items: MnemonWorkspaceSummary[];
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface SnapshotStore<State> {
|
|
37
|
+
getSnapshot(): State;
|
|
38
|
+
subscribe(listener: () => void): () => void;
|
|
39
|
+
}
|
|
40
|
+
/** Context shared by the released client runtime and the 0.1.2 controller split. */
|
|
41
|
+
export type MnemonClientContext = Context & {
|
|
18
42
|
connection: ConnectionHandle;
|
|
19
43
|
locale: LocaleRuntime;
|
|
44
|
+
sessions: {
|
|
45
|
+
list: SnapshotStore<MnemonSessionListState>;
|
|
46
|
+
};
|
|
47
|
+
workspaces: {
|
|
48
|
+
list: SnapshotStore<MnemonWorkspaceListState>;
|
|
49
|
+
};
|
|
20
50
|
};
|
|
51
|
+
export {};
|
|
@@ -748,6 +748,13 @@ export declare const zh: {
|
|
|
748
748
|
'config.embeddingManagedHint': string;
|
|
749
749
|
'config.embeddingEndpoint': string;
|
|
750
750
|
'config.embeddingModel': string;
|
|
751
|
+
'config.embeddingApiKey': string;
|
|
752
|
+
'config.embeddingApiKeyInvalid': string;
|
|
753
|
+
'config.embeddingProtocol': string;
|
|
754
|
+
'config.embeddingProtocolAuto': string;
|
|
755
|
+
'config.embeddingProtocolOllama': string;
|
|
756
|
+
'config.embeddingProtocolOpenai': string;
|
|
757
|
+
'config.embeddingProtocolInvalid': string;
|
|
751
758
|
'config.embeddingEndpointInvalid': string;
|
|
752
759
|
'config.embeddingModelInvalid': string;
|
|
753
760
|
'config.embeddingSecurity': string;
|
|
@@ -757,7 +764,9 @@ export declare const zh: {
|
|
|
757
764
|
'config.embeddingSaveBeforeTest': string;
|
|
758
765
|
'config.embeddingTestUnavailable': string;
|
|
759
766
|
'config.embeddingStatusAvailable': string;
|
|
767
|
+
'config.embeddingStatusAvailableWithProtocol': string;
|
|
760
768
|
'config.embeddingStatusUnavailable': string;
|
|
769
|
+
'config.embeddingStatusUnavailableWithProtocol': string;
|
|
761
770
|
'config.embeddingStatusFailed': string;
|
|
762
771
|
'config.providerGlobalLocation': string;
|
|
763
772
|
'config.providerGlobalLocationHint': string;
|
|
@@ -1655,6 +1664,13 @@ export declare const en: {
|
|
|
1655
1664
|
'config.embeddingManagedHint': string;
|
|
1656
1665
|
'config.embeddingEndpoint': string;
|
|
1657
1666
|
'config.embeddingModel': string;
|
|
1667
|
+
'config.embeddingApiKey': string;
|
|
1668
|
+
'config.embeddingApiKeyInvalid': string;
|
|
1669
|
+
'config.embeddingProtocol': string;
|
|
1670
|
+
'config.embeddingProtocolAuto': string;
|
|
1671
|
+
'config.embeddingProtocolOllama': string;
|
|
1672
|
+
'config.embeddingProtocolOpenai': string;
|
|
1673
|
+
'config.embeddingProtocolInvalid': string;
|
|
1658
1674
|
'config.embeddingEndpointInvalid': string;
|
|
1659
1675
|
'config.embeddingModelInvalid': string;
|
|
1660
1676
|
'config.embeddingSecurity': string;
|
|
@@ -1664,7 +1680,9 @@ export declare const en: {
|
|
|
1664
1680
|
'config.embeddingSaveBeforeTest': string;
|
|
1665
1681
|
'config.embeddingTestUnavailable': string;
|
|
1666
1682
|
'config.embeddingStatusAvailable': string;
|
|
1683
|
+
'config.embeddingStatusAvailableWithProtocol': string;
|
|
1667
1684
|
'config.embeddingStatusUnavailable': string;
|
|
1685
|
+
'config.embeddingStatusUnavailableWithProtocol': string;
|
|
1668
1686
|
'config.embeddingStatusFailed': string;
|
|
1669
1687
|
'config.providerGlobalLocation': string;
|
|
1670
1688
|
'config.providerGlobalLocationHint': string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { SessionListState } from '@deepseek-ai/dsh-client-runtime/client';
|
|
2
1
|
import type { SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
-
import type { MnemonClientContext } from './dsh-compat.ts';
|
|
2
|
+
import type { MnemonClientContext, MnemonSessionListState } from './dsh-compat.ts';
|
|
4
3
|
export declare const MNEMON_SUBAGENT_TOKEN_USAGE_KEY = "mnemonSubagentTokenUsage";
|
|
5
4
|
export interface MnemonTokenUsageProjection {
|
|
6
5
|
uncachedInputTokens: number;
|
|
@@ -13,9 +12,9 @@ export interface MnemonTokenUsageProjection {
|
|
|
13
12
|
* released official catalog component. All other consumers continue seeing
|
|
14
13
|
* DSH's complete-log `tokenUsage` value.
|
|
15
14
|
*/
|
|
16
|
-
export declare function scopeSubagentTokenUsage(state:
|
|
15
|
+
export declare function scopeSubagentTokenUsage(state: MnemonSessionListState): MnemonSessionListState;
|
|
17
16
|
/** Wrap the framework hook while preserving its selector/equality contract. */
|
|
18
|
-
export declare function createScopedUseSessions(useSessions: SnapshotSelectorHook<
|
|
17
|
+
export declare function createScopedUseSessions(useSessions: SnapshotSelectorHook<MnemonSessionListState>): SnapshotSelectorHook<MnemonSessionListState>;
|
|
19
18
|
/**
|
|
20
19
|
* Shadow the released official single-slot entry at a lower priority. The
|
|
21
20
|
* component and action factory are captured from the public slot ledger, so
|
|
@@ -12,4 +12,4 @@ export declare const DEFAULT_RUNTIME_USER_LIMIT_BYTES: number;
|
|
|
12
12
|
export declare const DEFAULT_RUNTIME_MAINTENANCE_MAX_TOKENS = 8192;
|
|
13
13
|
export declare const MAX_RUNTIME_MEMORY_LIMIT_BYTES: number;
|
|
14
14
|
export declare const MAX_RUNTIME_MAINTENANCE_MAX_TOKENS = 1000000;
|
|
15
|
-
export { DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL } from './shared/contracts.ts';
|
|
15
|
+
export { DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_EMBEDDING_PROTOCOL, MNEMON_EMBEDDING_PROTOCOLS } 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_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';
|
|
3
|
+
export { DEFAULT_IDLE_REVIEW_MS, DEFAULT_EMBEDDING_ENDPOINT, DEFAULT_EMBEDDING_MODEL, DEFAULT_EMBEDDING_PROTOCOL, 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;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { RpcResult, SettingsOperation } from './shared/contracts.ts';
|
|
2
2
|
export type { ClientConnectionHandle, ClientSettingsScope, ClientSettingsSnapshot, JsonPrimitive, JsonValue, RpcError, RpcResult, SettingsOperation, } from './shared/contracts.ts';
|
|
3
|
-
export type HostRpcHandler = (endpoint: string, payload: unknown) => Promise<RpcResult<unknown>>;
|
|
3
|
+
export type HostRpcHandler = (endpoint: string, payload: unknown, signal?: AbortSignal) => Promise<RpcResult<unknown>>;
|
|
4
4
|
export type HostRpcAuthority = 'trusted-host' | 'loopback';
|
|
5
|
+
/**
|
|
6
|
+
* DSH rc.2 requires this registration policy. DSH 0.1.2-alpha.1 accepts only
|
|
7
|
+
* the first two JavaScript arguments and safely ignores this trailing value.
|
|
8
|
+
* Keeping one unconditional call shape avoids runtime version detection.
|
|
9
|
+
*/
|
|
10
|
+
export interface HostRpcRegistrationOptions {
|
|
11
|
+
readonly authority: HostRpcAuthority;
|
|
12
|
+
}
|
|
5
13
|
export interface HostConnectionHandle {
|
|
6
14
|
rpc: {
|
|
7
|
-
handle(channel: string, handler: HostRpcHandler, options:
|
|
8
|
-
authority: HostRpcAuthority;
|
|
9
|
-
}): unknown;
|
|
15
|
+
handle(channel: string, handler: HostRpcHandler, options: HostRpcRegistrationOptions): unknown;
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
export interface HostSettingsScope<T> {
|
|
@@ -130,7 +136,15 @@ export type HostPreStepDecision = {
|
|
|
130
136
|
messages: HostUserMessage[];
|
|
131
137
|
};
|
|
132
138
|
export interface HostAgentContext {
|
|
133
|
-
|
|
139
|
+
/**
|
|
140
|
+
* `options` is optional and forwarded verbatim to the host. `prepend`
|
|
141
|
+
* places the listener at the head of the chain, which for a waterfall
|
|
142
|
+
* means it observes the fully assembled result. Omitting it keeps the
|
|
143
|
+
* previous two-argument behaviour exactly.
|
|
144
|
+
*/
|
|
145
|
+
on(name: string, listener: (...args: never[]) => unknown, options?: {
|
|
146
|
+
prepend?: boolean;
|
|
147
|
+
}): () => unknown;
|
|
134
148
|
effect(callback: () => (() => unknown) | void, label?: string): () => unknown;
|
|
135
149
|
get?(name: string): unknown;
|
|
136
150
|
}
|
|
@@ -278,6 +292,14 @@ export interface HostContextShape {
|
|
|
278
292
|
/** Cordis service publication; optional only for narrow test/headless shims. */
|
|
279
293
|
provide?(name: string, value?: unknown, check?: () => boolean): unknown;
|
|
280
294
|
inject(services: string[], callback: (ctx: HostContextShape) => void): unknown;
|
|
281
|
-
|
|
295
|
+
/**
|
|
296
|
+
* `options` is optional and forwarded verbatim to the host. `prepend`
|
|
297
|
+
* places the listener at the head of the chain, which for a waterfall
|
|
298
|
+
* means it observes the fully assembled result. Omitting it keeps the
|
|
299
|
+
* previous two-argument behaviour exactly.
|
|
300
|
+
*/
|
|
301
|
+
on(name: string, listener: (...args: never[]) => unknown, options?: {
|
|
302
|
+
prepend?: boolean;
|
|
303
|
+
}): () => unknown;
|
|
282
304
|
effect(callback: () => (() => unknown) | void, label?: string): () => unknown;
|
|
283
305
|
}
|
|
@@ -6,6 +6,7 @@ export declare const GUIDANCE_SECTION_NAME = "mnemon:routing";
|
|
|
6
6
|
export declare const RUNTIME_MEMORY_PROTOCOL_SECTION_NAME = "mnemon:runtime-memory-protocol";
|
|
7
7
|
export declare const RUNTIME_MEMORY_CONTEXT_NAME = "mnemon:runtime-memory";
|
|
8
8
|
export declare const ROUTING_GUIDANCE = "Use memory only when needed. Search Mnemon Documents for substantial project records. Call mnemon_recall for durable history or exact prior details; never infer a missing historical rule. Put only new user facts or explicit save/correction requests in mnemon_runtime_memory; never cache retrieved evidence. A write exists only after its receipt.";
|
|
9
|
+
export declare function memoryPromptText(value: string): string;
|
|
9
10
|
/** Replace the already-materialized Agent protocol and context with the Wake pinned during assembly. */
|
|
10
11
|
export declare function applyAgentMemoryViewWake<T extends {
|
|
11
12
|
sections: Array<{
|
|
@@ -22,6 +22,8 @@ export declare class MnemonLifecycle {
|
|
|
22
22
|
private readonly config;
|
|
23
23
|
private readonly runtimeSource?;
|
|
24
24
|
private readonly owners;
|
|
25
|
+
private readonly children;
|
|
26
|
+
private readonly memoryTurns;
|
|
25
27
|
private readonly counters;
|
|
26
28
|
/** Creation ids reserved before DSH publishes clean task-root Agents. */
|
|
27
29
|
private readonly taskAgentIds;
|
|
@@ -73,4 +75,6 @@ export declare class MnemonLifecycle {
|
|
|
73
75
|
private taskAgentModelRoute;
|
|
74
76
|
private taskAgentModelOptions;
|
|
75
77
|
private install;
|
|
78
|
+
/** Child memory ownership is independent of root-only reminders and idle review. */
|
|
79
|
+
private installChild;
|
|
76
80
|
}
|
|
@@ -29,7 +29,7 @@ export interface MnemonRuntimeGraph {
|
|
|
29
29
|
export interface MnemonAgentRuntimeSource {
|
|
30
30
|
readonly config: ResolvedConfig;
|
|
31
31
|
forAgent(agent: HostAgent): MnemonRuntimeGraph;
|
|
32
|
-
/**
|
|
32
|
+
/** Retain one runtime generation for an Agent turn or delegated child lifetime. */
|
|
33
33
|
bindAgentRuntime(agentId: string, graph: MnemonRuntimeGraph): () => void;
|
|
34
34
|
}
|
|
35
35
|
/**
|
package/lib/types/src/rpc.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ import { VersionUpdateManager } from './version-updates.ts';
|
|
|
9
9
|
export { MNEMON_ACTIVATION_CHANNEL, MNEMON_PACK_CHANNEL, MNEMON_READ_CHANNEL, MNEMON_WRITE_CHANNEL } from './channels.ts';
|
|
10
10
|
type RuntimeInput = MnemonService | LiveMnemonRuntime;
|
|
11
11
|
export declare function createReadHandler(input: RuntimeInput, lifecycle?: MnemonLifecycle, runtimeMemory?: RuntimeMemoryController, storage?: StorageScopeInspector, versions?: VersionUpdateManager): HostRpcHandler;
|
|
12
|
-
/**
|
|
13
|
-
* Expose only DSH read-routing activation to trusted Web hosts. Metadata,
|
|
14
|
-
* provider connections, credentials, and durable memory writes stay on the
|
|
15
|
-
* loopback-only write channel.
|
|
16
|
-
*/
|
|
12
|
+
/** Keep activation on a narrow, independently validated control endpoint. */
|
|
17
13
|
export declare function createActivationHandler(input: RuntimeInput): HostRpcHandler;
|
|
18
14
|
export declare function createWriteHandler(input: RuntimeInput, lifecycle?: MnemonLifecycle, runtimeMemory?: RuntimeMemoryController, versions?: VersionUpdateManager): HostRpcHandler;
|
|
19
|
-
/** Backup payloads contain private memory and
|
|
15
|
+
/** Backup payloads contain private memory and stay behind DSH browser authentication. */
|
|
20
16
|
export declare function createPackHandler(input: MnemonPackManager | LiveMnemonRuntime, writeEnabled?: boolean | (() => boolean)): HostRpcHandler;
|
|
21
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Register one call shape across DSH rc.2 and 0.1.2-alpha.1. The former
|
|
19
|
+
* enforces channel authority; the latter ignores the trailing options object
|
|
20
|
+
* after applying its uniform browser-session authentication boundary.
|
|
21
|
+
*/
|
|
22
22
|
export declare function registerRpc(connection: HostConnectionHandle, input: RuntimeInput, lifecycle?: MnemonLifecycle, runtimeMemory?: RuntimeMemoryController, storage?: StorageScopeInspector, packs?: MnemonPackManager, versions?: VersionUpdateManager, managementAuthority?: HostRpcAuthority): void;
|
|
@@ -10,6 +10,13 @@ export declare const MNEMON_SETTINGS_NAMESPACE = "mnemon";
|
|
|
10
10
|
export declare const MNEMON_UI_SETTINGS_NAMESPACE = "mnemon-ui";
|
|
11
11
|
export declare const DEFAULT_EMBEDDING_ENDPOINT = "http://localhost:11434";
|
|
12
12
|
export declare const DEFAULT_EMBEDDING_MODEL = "nomic-embed-text";
|
|
13
|
+
export declare const EMBEDDING_PROTOCOL_AUTO = "auto";
|
|
14
|
+
export declare const EMBEDDING_PROTOCOL_OLLAMA = "ollama";
|
|
15
|
+
export declare const EMBEDDING_PROTOCOL_OPENAI = "openai";
|
|
16
|
+
/** Default protocol defers to Mnemon's /v1 auto-detection. */
|
|
17
|
+
export declare const DEFAULT_EMBEDDING_PROTOCOL = "auto";
|
|
18
|
+
/** Wire protocols accepted by the embedding protocol override; single source for schema, resolver, and UI validation. */
|
|
19
|
+
export declare const MNEMON_EMBEDDING_PROTOCOLS: readonly ["auto", "ollama", "openai"];
|
|
13
20
|
export type JsonPrimitive = string | number | boolean | null;
|
|
14
21
|
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
15
22
|
[key: string]: JsonValue;
|
|
@@ -145,7 +152,7 @@ export interface Config {
|
|
|
145
152
|
displayMode?: 'sidebar' | 'buildin';
|
|
146
153
|
tabEnabled?: boolean;
|
|
147
154
|
writeEnabled?: boolean;
|
|
148
|
-
/**
|
|
155
|
+
/** DSH rc.2 management-channel authority; ignored by DSH 0.1.2-alpha.1. */
|
|
149
156
|
remoteAccess?: 'read-only' | 'trusted-host';
|
|
150
157
|
lifecycleEnabled?: boolean;
|
|
151
158
|
recallMode?: 'guided' | 'off';
|
|
@@ -161,16 +168,23 @@ export interface Config {
|
|
|
161
168
|
/** Model route used by clean, session-independent maintenance Agents. */
|
|
162
169
|
taskAgentModel?: TaskAgentModelConfig;
|
|
163
170
|
}
|
|
171
|
+
export type MnemonEmbeddingProtocol = (typeof MNEMON_EMBEDDING_PROTOCOLS)[number];
|
|
164
172
|
export interface MnemonEmbeddingConfig {
|
|
165
173
|
/** When false or omitted, Mnemon keeps its inherited environment and built-in defaults. */
|
|
166
174
|
enabled?: boolean;
|
|
167
175
|
endpoint?: string;
|
|
168
176
|
model?: string;
|
|
177
|
+
/** Optional Bearer token forwarded as MNEMON_EMBED_API_KEY for OpenAI-compatible endpoints. */
|
|
178
|
+
apiKey?: string;
|
|
179
|
+
/** Explicit wire-protocol override; 'auto' keeps Mnemon's /v1 auto-detection. */
|
|
180
|
+
protocol?: MnemonEmbeddingProtocol;
|
|
169
181
|
}
|
|
170
182
|
export interface ResolvedMnemonEmbeddingConfig {
|
|
171
183
|
enabled: boolean;
|
|
172
184
|
endpoint: string;
|
|
173
185
|
model: string;
|
|
186
|
+
apiKey: string;
|
|
187
|
+
protocol: MnemonEmbeddingProtocol;
|
|
174
188
|
}
|
|
175
189
|
export interface TaskAgentModelConfig {
|
|
176
190
|
mode?: 'inherit' | 'fixed';
|
|
@@ -232,6 +246,7 @@ export interface ResolvedConfig {
|
|
|
232
246
|
displayMode: 'sidebar' | 'buildin';
|
|
233
247
|
tabEnabled: boolean;
|
|
234
248
|
writeEnabled: boolean;
|
|
249
|
+
/** DSH rc.2 management-channel authority; ignored by DSH 0.1.2-alpha.1. */
|
|
235
250
|
remoteAccess: 'read-only' | 'trusted-host';
|
|
236
251
|
lifecycleEnabled: boolean;
|
|
237
252
|
recallMode: 'guided' | 'off';
|
|
@@ -248,6 +263,8 @@ export interface ResolvedConfig {
|
|
|
248
263
|
export interface MnemonEmbeddingStatus {
|
|
249
264
|
available: boolean;
|
|
250
265
|
model: string;
|
|
266
|
+
/** Protocol Mnemon resolved for the embedding endpoint; omitted when the CLI does not report one. */
|
|
267
|
+
protocol?: string;
|
|
251
268
|
totalInsights: number;
|
|
252
269
|
embedded: number;
|
|
253
270
|
coverage: string;
|
|
@@ -79,12 +79,12 @@ export declare class MnemonSubagentCoordinator {
|
|
|
79
79
|
documentsSnapshot(parent: HostAgent): import("./documents.ts").DocumentSnapshot;
|
|
80
80
|
documentGet(parent: HostAgent, id: string): DocumentView;
|
|
81
81
|
documentSearch(parent: HostAgent, query: string, includeArchived?: boolean, limit?: number): Promise<import("./documents.ts").DocumentSearchResult>;
|
|
82
|
-
/** Admit at most one model-facing Documents query for one
|
|
82
|
+
/** Admit at most one model-facing Documents query for one executing turn. */
|
|
83
83
|
claimDocumentSearch(parent: HostAgent): boolean;
|
|
84
84
|
recall(parent: HostAgent, request: SearchRequest, signal: AbortSignal, options?: {
|
|
85
85
|
requirePinnedView?: boolean;
|
|
86
86
|
}): Promise<RecallResult>;
|
|
87
|
-
/** Bind a model read to the Source state pinned by its
|
|
87
|
+
/** Bind a model read to the Source state pinned by its own executing turn. */
|
|
88
88
|
scopeRecallRequest(agent: HostAgent, request: SearchRequest, requirePinnedView?: boolean): SearchRequest;
|
|
89
89
|
private scopeRecallWithAuthority;
|
|
90
90
|
scopeRelatedMemoryBody(agent: HostAgent, memoryBodyId?: string, requirePinnedView?: boolean): string | undefined;
|
package/lib/types/src/tools.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import type { MnemonAgentRuntimeSource } from './live-runtime.ts';
|
|
|
5
5
|
import { MnemonSubagentCoordinator } from './subagent.ts';
|
|
6
6
|
import { type MnemonService } from './service.ts';
|
|
7
7
|
type AgentRuntimeSource = MnemonAgentRuntimeSource;
|
|
8
|
-
/**
|
|
8
|
+
/** Model tools use the executing Agent's pinned runtime and deterministic service. */
|
|
9
9
|
export declare function registerTools(ctx: HostContextShape, serviceOrSource: MnemonService | AgentRuntimeSource, coordinator: MnemonSubagentCoordinator, runtimeMemory?: RuntimeMemoryController, documents?: DocumentManager): void;
|
|
10
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
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",
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
},
|
|
115
115
|
"client": {
|
|
116
116
|
"inject": [
|
|
117
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
118
117
|
"@deepseek-ai/dsh-client-connection",
|
|
119
118
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
119
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
120
120
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
121
121
|
"@deepseek-ai/dsh-client-locale"
|
|
122
122
|
],
|
|
@@ -133,7 +133,9 @@
|
|
|
133
133
|
"verify:build": "node scripts/verify-deterministic-build.mjs",
|
|
134
134
|
"verify:headless": "node scripts/verify-headless-profile.mjs",
|
|
135
135
|
"verify:package": "node scripts/verify-package-contents.mjs && node scripts/verify-public-entries.mjs && pnpm run lint:package",
|
|
136
|
-
"verify": "pnpm run typecheck && pnpm run test && pnpm run verify:build && pnpm run verify:headless && pnpm run verify:package"
|
|
136
|
+
"verify": "pnpm run typecheck && pnpm run test && pnpm run verify:build && pnpm run verify:headless && pnpm run verify:package",
|
|
137
|
+
"dsh:link-source": "node scripts/link-dsh-source.mjs",
|
|
138
|
+
"dsh:restore-registry": "node scripts/link-dsh-source.mjs --restore"
|
|
137
139
|
},
|
|
138
140
|
"dependencies": {
|
|
139
141
|
"fflate": "^0.8.3",
|
|
@@ -142,7 +144,7 @@
|
|
|
142
144
|
"zod": "^4.4.3"
|
|
143
145
|
},
|
|
144
146
|
"peerDependencies": {
|
|
145
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6 || ^0.1.1-rc.1",
|
|
147
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6 || ^0.1.1-rc.1 || ^0.1.2-alpha.1",
|
|
146
148
|
"react": "^18.2.0",
|
|
147
149
|
"react-dom": "^18.2.0"
|
|
148
150
|
},
|
|
@@ -150,15 +152,24 @@
|
|
|
150
152
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
151
153
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
152
154
|
"@deepseek-ai/dsh": "0.1.1-rc.2",
|
|
155
|
+
"@deepseek-ai/dsh-agent": "0.1.1-rc.2",
|
|
156
|
+
"@deepseek-ai/dsh-agent-loop": "0.1.1-rc.2",
|
|
153
157
|
"@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
|
|
154
158
|
"@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
|
|
155
|
-
"@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
|
|
156
159
|
"@deepseek-ai/dsh-client-ui-conversation": "0.1.1-rc.2",
|
|
157
160
|
"@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
|
|
161
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.1.1-rc.2",
|
|
158
162
|
"@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
|
|
159
163
|
"@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
|
|
160
164
|
"@deepseek-ai/dsh-client-ui-tool": "0.1.1-rc.2",
|
|
165
|
+
"@deepseek-ai/dsh-llm": "0.1.1-rc.2",
|
|
166
|
+
"@deepseek-ai/dsh-session": "0.1.1-rc.2",
|
|
167
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.1.1-rc.2",
|
|
168
|
+
"@deepseek-ai/dsh-session-query": "0.1.1-rc.2",
|
|
169
|
+
"@deepseek-ai/dsh-subagent": "0.1.1-rc.2",
|
|
170
|
+
"@deepseek-ai/dsh-subagent-spawn-in-process": "0.1.1-rc.2",
|
|
161
171
|
"@deepseek-ai/dsh-system-prompt": "0.1.1-rc.2",
|
|
172
|
+
"@deepseek-ai/dsh-tools": "0.1.1-rc.2",
|
|
162
173
|
"@testing-library/react": "^16.3.0",
|
|
163
174
|
"@types/node": "^22.0.0",
|
|
164
175
|
"@types/react": "^18.3.0",
|