dsh-mnemon-source-memory-spaces 0.5.0-rc.1

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/lib/testing.js ADDED
@@ -0,0 +1,106 @@
1
+ import { a as MemoryProviderCatalog, n as PrivateMemorySpaceProviderHost, t as createMemorySpaceProviderPlugin } from "./plugin-DlsNeZbQ.js";
2
+ import { n as deepFreeze } from "./definitions-DfmOqJjR.js";
3
+ import { Context } from "@deepseek-ai/cordis";
4
+ //#region src/testing.ts
5
+ /** Real private-child registration and factory validation, without exposing its Host/Registry. */
6
+ async function mountMemorySpaceProvider(module, options) {
7
+ const context = new Context();
8
+ const host = new PrivateMemorySpaceProviderHost(options.sourceInstanceId ?? "test-memory-spaces");
9
+ const instanceId = options.instanceId ?? module.id;
10
+ const plugin = createMemorySpaceProviderPlugin({
11
+ instanceId,
12
+ module,
13
+ config: options.config
14
+ }, host);
15
+ const bound = {
16
+ ...plugin,
17
+ apply: (ctx, config) => plugin.apply(ctx, config)
18
+ };
19
+ const child = context.plugin(bound, options.config);
20
+ try {
21
+ await child.await();
22
+ if (!host.has(instanceId)) throw new Error(`Memory Space Provider child did not install a definition: ${instanceId}`);
23
+ const snapshot = host.snapshot();
24
+ const adapters = /* @__PURE__ */ new Set();
25
+ let closing;
26
+ return Object.freeze({
27
+ get registered() {
28
+ return host.has(instanceId);
29
+ },
30
+ descriptor: deepFreeze(snapshot.descriptors()[0]),
31
+ manifest: snapshot.entries[0].definition.manifest,
32
+ createAdapter: (input) => {
33
+ if (closing !== void 0) throw new Error("Memory Space Provider test is disposed");
34
+ const adapter = snapshot.adapterRegistry().create(input).get(instanceId);
35
+ adapters.add(adapter);
36
+ return adapter;
37
+ },
38
+ dispose: () => {
39
+ closing ??= Promise.resolve().then(async () => {
40
+ const failures = [];
41
+ for (const adapter of adapters) try {
42
+ await adapter.dispose?.();
43
+ } catch (error) {
44
+ failures.push(error);
45
+ }
46
+ adapters.clear();
47
+ try {
48
+ await context.fiber.dispose();
49
+ } catch (error) {
50
+ failures.push(error);
51
+ }
52
+ if (failures.length > 0) throw new AggregateError(failures, "Memory Space Provider test cleanup failed");
53
+ });
54
+ return closing;
55
+ }
56
+ });
57
+ } catch (error) {
58
+ await context.fiber.dispose();
59
+ throw error;
60
+ }
61
+ }
62
+ /** Driver fixture only: real descriptor validation, no Core or service singleton. */
63
+ function createMemorySpaceProviderFixture(descriptor, input = {}, options) {
64
+ const instanceId = options.instanceId ?? descriptor.id;
65
+ const catalog = new MemoryProviderCatalog([{
66
+ ...descriptor,
67
+ id: instanceId,
68
+ ...instanceId === descriptor.id ? {} : { typeId: descriptor.id }
69
+ }]);
70
+ const connection = catalog.normalize(instanceId, input);
71
+ const publicConnection = catalog.public(instanceId, connection);
72
+ const body = {
73
+ id: options.memoryBodyId ?? "test-memory",
74
+ name: "Test memory",
75
+ description: "Provider-owned test fixture",
76
+ active: true,
77
+ dbPath: "",
78
+ createdAt: "2026-08-30T00:00:00.000Z",
79
+ updatedAt: "2026-08-30T00:00:00.000Z",
80
+ provider: {
81
+ id: instanceId,
82
+ ...instanceId === descriptor.id ? {} : { typeId: descriptor.id },
83
+ label: descriptor.label,
84
+ kind: descriptor.kind,
85
+ origin: descriptor.origin,
86
+ location: String(connection.endpoint ?? options.dataDir),
87
+ apiKeyConfigured: publicConnection.configuredSecrets.includes("apiKey"),
88
+ ...publicConnection,
89
+ capabilities: structuredClone(descriptor.capabilities)
90
+ }
91
+ };
92
+ return {
93
+ body,
94
+ authority: {
95
+ runner: { effectiveDataDir: () => options.dataDir },
96
+ list: () => [body],
97
+ providerConnection(id, expectedProviderId) {
98
+ if (id !== body.id || expectedProviderId !== void 0 && expectedProviderId !== instanceId) throw new Error("Provider attempted to cross its test authority boundary");
99
+ return structuredClone(connection);
100
+ }
101
+ },
102
+ connection
103
+ };
104
+ }
105
+ //#endregion
106
+ export { createMemorySpaceProviderFixture, mountMemorySpaceProvider };
@@ -0,0 +1,10 @@
1
+ import type { JSX } from 'react';
2
+ import type { MemoryProviderIcon, MemoryProviderId } from '../contracts.ts';
3
+ export interface ProviderIconProps {
4
+ providerId: MemoryProviderId;
5
+ icon?: MemoryProviderIcon | undefined;
6
+ className?: string | undefined;
7
+ title?: string | undefined;
8
+ }
9
+ /** Only the owning plugin supplies image data; unknown brands get a neutral mark. */
10
+ export declare function ProviderIcon({ providerId, icon, className, title }: ProviderIconProps): JSX.Element;
@@ -0,0 +1,39 @@
1
+ import type { CreateMemoryBodyRequest, EntityView, Insight, MemoryBody, MemoryBodyView, MemoryBodyMetadataMaintenanceResult, MemoryBodyCatalog, MemoryGraphSnapshot, MemoryListRequest, MemoryListView, MemoryReadSource, RememberRequest, SearchRequest, UpdateMemoryBodyRequest } from '../contracts.ts';
2
+ /** Source-owned structural page API; the default bundle may supply agent-assisted callbacks. */
3
+ export interface MemorySpacesPageClient {
4
+ bodies(): Promise<MemoryBodyCatalog>;
5
+ bodyDirectory(): Promise<MemoryBodyCatalog>;
6
+ graph(memoryBodyIds?: string[]): Promise<MemoryGraphSnapshot>;
7
+ list(request?: MemoryListRequest): Promise<MemoryListView>;
8
+ entities(entity?: string, limit?: number): Promise<EntityView>;
9
+ search(request: SearchRequest): Promise<SearchResponse>;
10
+ agentSearch(request: SearchRequest): Promise<AgentSearchResponse>;
11
+ related(id: string, memoryBodyId?: string): Promise<Insight[]>;
12
+ remember(request: RememberRequest): Promise<Record<string, unknown>>;
13
+ supervise(content: string, idempotencyKey?: string): Promise<{
14
+ delegated: true;
15
+ sessionId: string;
16
+ runId: string;
17
+ provider: string;
18
+ summary: string;
19
+ action: string;
20
+ memoryBodyIds: string[];
21
+ }>;
22
+ forget(id: string, memoryBodyId?: string): Promise<Record<string, unknown>>;
23
+ createBody(request: CreateMemoryBodyRequest): Promise<MemoryBody>;
24
+ updateBody(memoryBodyId: string, request: UpdateMemoryBodyRequest): Promise<MemoryBody>;
25
+ reconnectBody(memoryBodyId: string): Promise<MemoryBodyView>;
26
+ maintainBodyMetadata(memoryBodyIds: string[]): Promise<MemoryBodyMetadataMaintenanceResult>;
27
+ deleteBody(memoryBodyId: string): Promise<MemoryBody>;
28
+ }
29
+ export interface SearchResponse {
30
+ results: Insight[];
31
+ sources?: MemoryReadSource[];
32
+ }
33
+ export interface AgentSearchResponse extends SearchResponse {
34
+ answer: string;
35
+ citations: string[];
36
+ delegation: {
37
+ runId: string;
38
+ };
39
+ }
@@ -0,0 +1,72 @@
1
+ import type { JSX } from 'react';
2
+ import { type Insight, type MemoryBodyMetadataUpdate, type MemoryBodyProvider, type MemoryBodyView } from '../contracts.ts';
3
+ import type { MemorySpacesPageClient } from './api.ts';
4
+ import type { MemoryPersistenceStrategy } from '../contracts.ts';
5
+ export interface MemoryPlacementSettings {
6
+ setPath(path: string[], value: unknown): Promise<void>;
7
+ }
8
+ export interface MemoryPlacementPageConfig {
9
+ persistenceStrategy?: MemoryPersistenceStrategy;
10
+ }
11
+ export interface MemorySpacesPageStatus {
12
+ defaultRecallLimit?: number;
13
+ }
14
+ export declare function nativeBodyProvider(provider: MemoryBodyProvider): boolean;
15
+ export declare function OverviewPage(props: {
16
+ client: MemorySpacesPageClient;
17
+ metadataClient: MemorySpacesPageClient;
18
+ revision: number;
19
+ activationEnabled: boolean;
20
+ writeEnabled: boolean;
21
+ agentAvailable: boolean;
22
+ fallbackBodies: MemoryBodyView[];
23
+ fallbackDirectory: string | undefined;
24
+ catalogKnown: boolean;
25
+ onMutate: () => void;
26
+ onAgentRefresh: () => void;
27
+ onBodyReconnect: (body: MemoryBodyView) => void;
28
+ onBodyMetadata: (updates: readonly MemoryBodyMetadataUpdate[]) => void;
29
+ onExplore: (query: string) => void;
30
+ }): JSX.Element;
31
+ export declare function ExplorePage(props: {
32
+ client: MemorySpacesPageClient;
33
+ agentClient: MemorySpacesPageClient;
34
+ agentAvailable: boolean;
35
+ status: MemorySpacesPageStatus | null;
36
+ seed: string;
37
+ writeEnabled: boolean;
38
+ onForget: (insight: Insight) => Promise<void>;
39
+ }): JSX.Element;
40
+ export declare function EntitiesPage(props: {
41
+ client: MemorySpacesPageClient;
42
+ revision: number;
43
+ writeEnabled: boolean;
44
+ onForget: (insight: Insight) => Promise<void>;
45
+ onExplore: (query: string) => void;
46
+ }): JSX.Element;
47
+ export declare function PersistenceStrategyDialog(props: {
48
+ client: MemorySpacesPageClient;
49
+ settingsScope: MemoryPlacementSettings;
50
+ config: MemoryPlacementPageConfig | undefined;
51
+ writable: boolean;
52
+ agentAvailable: boolean;
53
+ onClose: () => void;
54
+ }): JSX.Element;
55
+ export declare function RememberPage(props: {
56
+ client: MemorySpacesPageClient;
57
+ agentAvailable: boolean;
58
+ memoryBodies: MemoryBodyView[];
59
+ writeEnabled: boolean;
60
+ seed: string;
61
+ onMutate: () => void;
62
+ onClose: () => void;
63
+ onComplete?: () => void;
64
+ }): JSX.Element;
65
+ export declare function ListPage(props: {
66
+ client: MemorySpacesPageClient;
67
+ revision: number;
68
+ writeEnabled: boolean;
69
+ onForget: (insight: Insight) => Promise<void>;
70
+ onClone: (insight: Insight) => void;
71
+ onExplore: (query: string) => void;
72
+ }): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { MemoryProviderConfigField, MemoryProviderDescriptor } from '../contracts.ts';
2
+ import type { MnemonTranslate } from 'dsh-mnemon/client';
3
+ export declare function providerDisplayLabel(_providerId: string, label: string): string;
4
+ export declare function providerSummary(t: MnemonTranslate, provider: MemoryProviderDescriptor): string;
5
+ export declare function providerFieldLabel(t: MnemonTranslate, field: MemoryProviderConfigField): string;
6
+ export declare function providerOptionLabel(t: MnemonTranslate, option: NonNullable<MemoryProviderConfigField['options']>[number]): string;
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from 'react';
2
+ import { installMemorySourceUI, type MemorySourcePageProps, type MnemonSourceManagementClient, type MnemonTranslate } from 'dsh-mnemon/client';
3
+ import type { MemorySpacesStatus } from '../contracts.ts';
4
+ import type { MemorySpacesPageClient } from './api.ts';
5
+ /** The adapter never gets a transport or chooses another Source instance. */
6
+ export declare function memorySpacesPageClient(management: MnemonSourceManagementClient): MemorySpacesPageClient & {
7
+ status(): Promise<MemorySpacesStatus>;
8
+ canAssist(operation: string): boolean;
9
+ };
10
+ type Page = 'spaces' | 'explore' | 'entities' | 'remember' | 'content';
11
+ export declare function MemorySpacesSourcePage(props: MemorySourcePageProps & {
12
+ page: Page;
13
+ }): ReactNode;
14
+ export declare function installMemorySpacesUI(ctx: Parameters<typeof installMemorySourceUI>[0], t?: MnemonTranslate): () => void;
15
+ export declare const inject: string[];
16
+ export declare function apply(ctx: Parameters<typeof installMemorySourceUI>[0]): void;
17
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './client/pages.tsx';
2
+ export type * from './client/api.ts';
3
+ export * from './client/ui.tsx';