@atomicmemory/sdk
Advanced tools
| import { HindsightProvider, Mem0Provider, AtomicMemoryProvider, noopMemoryPipeline, UnsupportedOperationError } from './chunk-YBN5Y627.js'; | ||
| // src/memory/providers/registry.ts | ||
| var defaultRegistry = { | ||
| atomicmemory: (config) => ({ | ||
| provider: new AtomicMemoryProvider(config) | ||
| }), | ||
| mem0: (config) => ({ | ||
| provider: new Mem0Provider(config) | ||
| }), | ||
| hindsight: (config) => ({ | ||
| provider: new HindsightProvider(config) | ||
| }) | ||
| }; | ||
| // src/memory/memory-service.ts | ||
| var MemoryService = class { | ||
| constructor(config) { | ||
| this.config = config; | ||
| this.defaultProviderName = config.defaultProvider; | ||
| } | ||
| config; | ||
| providers = /* @__PURE__ */ new Map(); | ||
| pipelines = /* @__PURE__ */ new Map(); | ||
| defaultProviderName; | ||
| async initialize(registry = defaultRegistry) { | ||
| for (const [name, providerConfig] of Object.entries( | ||
| this.config.providerConfigs | ||
| )) { | ||
| const factory = registry[name]; | ||
| if (!factory) continue; | ||
| const registration = factory(providerConfig); | ||
| this.providers.set(name, registration.provider); | ||
| this.pipelines.set( | ||
| name, | ||
| registration.pipeline ?? noopMemoryPipeline | ||
| ); | ||
| if (registration.provider.initialize) { | ||
| await registration.provider.initialize(); | ||
| } | ||
| } | ||
| } | ||
| getProvider(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| const provider = this.providers.get(providerName); | ||
| if (!provider) { | ||
| throw new Error( | ||
| `Provider "${providerName}" is not registered` | ||
| ); | ||
| } | ||
| return provider; | ||
| } | ||
| getAvailableProviders() { | ||
| return Array.from(this.providers.keys()); | ||
| } | ||
| /** | ||
| * Provider names declared in the SDK configuration, regardless of whether | ||
| * they have been initialized yet. Useful for UI and getter paths that | ||
| * need to advertise capabilities before `initialize()` has run. | ||
| */ | ||
| getConfiguredProviders() { | ||
| return Object.keys(this.config.providerConfigs); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Core operations | ||
| // ----------------------------------------------------------------------- | ||
| async ingest(input, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| if (pipeline.preprocessIngest) { | ||
| const inputs = await pipeline.preprocessIngest(input); | ||
| const results = []; | ||
| for (const i of inputs) { | ||
| const result2 = await provider.ingest(i); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result2, i); | ||
| } | ||
| results.push(result2); | ||
| } | ||
| return mergeIngestResults(results); | ||
| } | ||
| const result = await provider.ingest(input); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result, input); | ||
| } | ||
| return result; | ||
| } | ||
| async search(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRequest = pipeline.preprocessSearch ? await pipeline.preprocessSearch(request) : request; | ||
| const page = await provider.search(processedRequest); | ||
| return pipeline.postprocessSearch ? await pipeline.postprocessSearch(page, processedRequest) : page; | ||
| } | ||
| async get(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRef = pipeline.preprocessGet ? await pipeline.preprocessGet(ref) : ref; | ||
| const memory = await provider.get(processedRef); | ||
| return pipeline.postprocessGet ? await pipeline.postprocessGet(memory, processedRef) : memory; | ||
| } | ||
| async delete(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| await provider.delete(ref); | ||
| } | ||
| async list(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const page = await provider.list(request); | ||
| return pipeline.postprocessList ? await pipeline.postprocessList(page, request) : page; | ||
| } | ||
| async package(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const packager = provider.getExtension?.("package"); | ||
| if (!packager) { | ||
| throw new UnsupportedOperationError( | ||
| provider.name, | ||
| "package" | ||
| ); | ||
| } | ||
| return packager.package(request); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Internals | ||
| // ----------------------------------------------------------------------- | ||
| getPipeline(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| return this.pipelines.get(providerName) ?? noopMemoryPipeline; | ||
| } | ||
| }; | ||
| function mergeIngestResults(results) { | ||
| return { | ||
| created: results.flatMap((r) => r.created), | ||
| updated: results.flatMap((r) => r.updated), | ||
| unchanged: results.flatMap((r) => r.unchanged) | ||
| }; | ||
| } | ||
| // src/client/memory-client.ts | ||
| var MemoryClient = class { | ||
| service; | ||
| initialized = false; | ||
| constructor(config) { | ||
| const providerConfigs = { ...config.providers }; | ||
| const defaultProvider = config.defaultProvider ?? pickFirstProviderKey(providerConfigs); | ||
| if (!defaultProvider) { | ||
| throw new Error( | ||
| 'MemoryClient requires at least one provider config. Pass e.g. { providers: { atomicmemory: { apiUrl: "..." } } }.' | ||
| ); | ||
| } | ||
| this.service = new MemoryService({ | ||
| defaultProvider, | ||
| providerConfigs | ||
| }); | ||
| } | ||
| /** | ||
| * Initialize all configured providers. Must be called before any | ||
| * memory operation. Idempotent. | ||
| */ | ||
| async initialize(registry = defaultRegistry) { | ||
| if (this.initialized) return; | ||
| await this.service.initialize(registry); | ||
| this.initialized = true; | ||
| } | ||
| /** | ||
| * Write memory(ies). Input supports `text`, `messages`, or `memory` modes. | ||
| */ | ||
| async ingest(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Ingest without any application-layer gating. Equivalent to `ingest()` | ||
| * on the core client; application wrappers override the gated variant | ||
| * while delegating this path straight through. | ||
| */ | ||
| async ingestDirect(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Search for memories matching the request. | ||
| */ | ||
| async search(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Search without application-layer gating. See `ingestDirect` for the | ||
| * rationale. | ||
| */ | ||
| async searchDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Build an injection-ready context package from a scoped request. | ||
| * Provider must implement the `package` extension. | ||
| */ | ||
| async package(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Package without application-layer gating. | ||
| */ | ||
| async packageDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Fetch a single memory by reference. | ||
| */ | ||
| async get(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.get(ref); | ||
| } | ||
| /** | ||
| * Delete a single memory by reference. | ||
| */ | ||
| async delete(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.delete(ref); | ||
| } | ||
| /** | ||
| * List memories within a scope. | ||
| */ | ||
| async list(request) { | ||
| this.assertInitialized(); | ||
| return this.service.list(request); | ||
| } | ||
| /** | ||
| * Report the capability surface of the default (or named) provider. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| */ | ||
| capabilities(providerName) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(providerName).capabilities(); | ||
| } | ||
| /** | ||
| * Resolve a named extension on the default (or named) provider. | ||
| * Returns `undefined` when the provider does not advertise the | ||
| * extension. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const pkg = memory.getExtension<Packager>('package'); | ||
| * ``` | ||
| */ | ||
| getExtension(extensionName, providerName) { | ||
| this.assertInitialized(); | ||
| const provider = this.service.getProvider(providerName); | ||
| return provider.getExtension?.(extensionName); | ||
| } | ||
| /** | ||
| * Aggregate status of all configured providers. Never throws: | ||
| * uninitialized providers report `initialized: false` and | ||
| * `capabilities: null`. | ||
| */ | ||
| getProviderStatus() { | ||
| const configured = this.service.getConfiguredProviders(); | ||
| const available = new Set(this.service.getAvailableProviders()); | ||
| return configured.map((name) => { | ||
| if (!available.has(name)) { | ||
| return { name, initialized: false, capabilities: null }; | ||
| } | ||
| return { | ||
| name, | ||
| initialized: true, | ||
| capabilities: this.service.getProvider(name).capabilities() | ||
| }; | ||
| }); | ||
| } | ||
| /** | ||
| * Access the full AtomicMemory namespace handle (lifecycle, audit, | ||
| * lessons, config, agents). Returns `undefined` when the client is | ||
| * not yet initialized, the `atomicmemory` provider was not included | ||
| * in the `providers` config, or that provider does not advertise the | ||
| * namespace handle. This getter intentionally never throws — callers | ||
| * can guard with a truthy check and let the handle's own methods | ||
| * raise if used incorrectly. | ||
| */ | ||
| get atomicmemory() { | ||
| if (!this.initialized) return void 0; | ||
| if (!this.service.getConfiguredProviders().includes("atomicmemory")) { | ||
| return void 0; | ||
| } | ||
| const provider = this.service.getProvider("atomicmemory"); | ||
| return provider.getExtension?.("atomicmemory.base"); | ||
| } | ||
| /** | ||
| * Low-level escape hatch for callers that need the concrete provider. | ||
| */ | ||
| getProvider(name) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(name); | ||
| } | ||
| assertInitialized() { | ||
| if (!this.initialized) { | ||
| throw new Error( | ||
| "MemoryClient is not initialized. Call `await client.initialize()` first." | ||
| ); | ||
| } | ||
| } | ||
| }; | ||
| function pickFirstProviderKey(providers) { | ||
| for (const [key, value] of Object.entries(providers)) { | ||
| if (value !== void 0 && key !== "default") return key; | ||
| } | ||
| return void 0; | ||
| } | ||
| export { MemoryClient }; | ||
| //# sourceMappingURL=chunk-265G225P.js.map | ||
| //# sourceMappingURL=chunk-265G225P.js.map |
| {"version":3,"sources":["../src/memory/providers/registry.ts","../src/memory/memory-service.ts","../src/client/memory-client.ts"],"names":["result"],"mappings":";;;AAoBO,IAAM,eAAA,GAAoC;AAAA,EAC/C,YAAA,EAAc,CAAC,MAAA,MAAoE;AAAA,IACjF,QAAA,EAAU,IAAI,oBAAA,CAAqB,MAAM;AAAA,GAC3C,CAAA;AAAA,EACA,IAAA,EAAM,CAAC,MAAA,MAA4D;AAAA,IACjE,QAAA,EAAU,IAAI,YAAA,CAAa,MAAM;AAAA,GACnC,CAAA;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,MAAiE;AAAA,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A,CAAQ,WAAA,CAAY,cAAc,CAAA;AACxD,IAAA,OAAO,QAAA,CAAS,eAAmC,mBAAmB,CAAA;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY,IAAA,EAA+B;AACzC,IAAA,IAAA,CAAK,iBAAA,EAAkB;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,IAAI,CAAA;AAAA,EACtC;AAAA,EAEQ,iBAAA,GAA0B;AAChC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,SAAA,EAAwD;AACpF,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpD,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,GAAA,KAAQ,SAAA,EAAW,OAAO,GAAA;AAAA,EACvD;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-265G225P.js","sourcesContent":["/**\n * @file Memory Provider Registry\n *\n * Maps provider names to factory functions that create\n * MemoryProviderRegistration instances from configuration.\n */\n\nimport type { MemoryProviderRegistration } from '../registration';\nimport type { AtomicMemoryProviderConfig } from '../atomicmemory-provider/types';\nimport { AtomicMemoryProvider } from '../atomicmemory-provider/atomicmemory-provider';\nimport type { Mem0ProviderConfig } from '../mem0-provider/types';\nimport { Mem0Provider } from '../mem0-provider/mem0-provider';\nimport type { HindsightProviderConfig } from '../hindsight-provider/types';\nimport { HindsightProvider } from '../hindsight-provider/hindsight-provider';\n\nexport type ProviderRegistry = Record<\n string,\n (config: any) => MemoryProviderRegistration\n>;\n\nexport const defaultRegistry: ProviderRegistry = {\n atomicmemory: (config: AtomicMemoryProviderConfig): MemoryProviderRegistration => ({\n provider: new AtomicMemoryProvider(config),\n }),\n mem0: (config: Mem0ProviderConfig): MemoryProviderRegistration => ({\n provider: new Mem0Provider(config),\n }),\n hindsight: (config: HindsightProviderConfig): MemoryProviderRegistration => ({\n provider: new HindsightProvider(config),\n }),\n};\n","/**\n * @file Memory Service\n *\n * Replaces UnifiedContextService. Routes operations to the correct\n * provider and applies optional processing pipelines.\n */\n\nimport type { MemoryProvider, Packager } from './provider';\nimport type { MemoryProcessingPipeline } from './pipeline';\nimport { noopMemoryPipeline } from './pipeline';\nimport type { MemoryProviderRegistration } from './registration';\nimport { UnsupportedOperationError } from './errors';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n} from './types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from './providers/registry';\n\nexport interface MemoryServiceConfig {\n defaultProvider: string;\n providerConfigs: Record<string, unknown>;\n}\n\nexport class MemoryService {\n private providers = new Map<string, MemoryProvider>();\n private pipelines = new Map<string, MemoryProcessingPipeline>();\n private defaultProviderName: string;\n\n constructor(private readonly config: MemoryServiceConfig) {\n this.defaultProviderName = config.defaultProvider;\n }\n\n async initialize(\n registry: ProviderRegistry = defaultRegistry\n ): Promise<void> {\n for (const [name, providerConfig] of Object.entries(\n this.config.providerConfigs\n )) {\n const factory = registry[name];\n if (!factory) continue;\n const registration: MemoryProviderRegistration = factory(providerConfig);\n this.providers.set(name, registration.provider);\n this.pipelines.set(\n name,\n registration.pipeline ?? noopMemoryPipeline\n );\n\n if (registration.provider.initialize) {\n await registration.provider.initialize();\n }\n }\n }\n\n getProvider(name?: string): MemoryProvider {\n const providerName = name ?? this.defaultProviderName;\n const provider = this.providers.get(providerName);\n if (!provider) {\n throw new Error(\n `Provider \"${providerName}\" is not registered`\n );\n }\n return provider;\n }\n\n getAvailableProviders(): string[] {\n return Array.from(this.providers.keys());\n }\n\n /**\n * Provider names declared in the SDK configuration, regardless of whether\n * they have been initialized yet. Useful for UI and getter paths that\n * need to advertise capabilities before `initialize()` has run.\n */\n getConfiguredProviders(): string[] {\n return Object.keys(this.config.providerConfigs);\n }\n\n // -----------------------------------------------------------------------\n // Core operations\n // -----------------------------------------------------------------------\n\n async ingest(\n input: IngestInput,\n providerName?: string\n ): Promise<IngestResult> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n if (pipeline.preprocessIngest) {\n const inputs = await pipeline.preprocessIngest(input);\n const results: IngestResult[] = [];\n for (const i of inputs) {\n const result = await provider.ingest(i);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, i);\n }\n results.push(result);\n }\n return mergeIngestResults(results);\n }\n\n const result = await provider.ingest(input);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, input);\n }\n return result;\n }\n\n async search(\n request: SearchRequest,\n providerName?: string\n ): Promise<SearchResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRequest = pipeline.preprocessSearch\n ? await pipeline.preprocessSearch(request)\n : request;\n\n const page = await provider.search(processedRequest);\n\n return pipeline.postprocessSearch\n ? await pipeline.postprocessSearch(page, processedRequest)\n : page;\n }\n\n async get(\n ref: MemoryRef,\n providerName?: string\n ): Promise<Memory | null> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRef = pipeline.preprocessGet\n ? await pipeline.preprocessGet(ref)\n : ref;\n\n const memory = await provider.get(processedRef);\n\n return pipeline.postprocessGet\n ? await pipeline.postprocessGet(memory, processedRef)\n : memory;\n }\n\n async delete(\n ref: MemoryRef,\n providerName?: string\n ): Promise<void> {\n const provider = this.getProvider(providerName);\n await provider.delete(ref);\n }\n\n async list(\n request: ListRequest,\n providerName?: string\n ): Promise<ListResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const page = await provider.list(request);\n\n return pipeline.postprocessList\n ? await pipeline.postprocessList(page, request)\n : page;\n }\n\n async package(\n request: PackageRequest,\n providerName?: string\n ): Promise<ContextPackage> {\n const provider = this.getProvider(providerName);\n const packager = provider.getExtension?.<Packager>('package');\n if (!packager) {\n throw new UnsupportedOperationError(\n provider.name,\n 'package'\n );\n }\n return packager.package(request);\n }\n\n // -----------------------------------------------------------------------\n // Internals\n // -----------------------------------------------------------------------\n\n private getPipeline(\n name?: string\n ): MemoryProcessingPipeline {\n const providerName = name ?? this.defaultProviderName;\n return (\n this.pipelines.get(providerName) ?? noopMemoryPipeline\n );\n }\n}\n\nfunction mergeIngestResults(\n results: IngestResult[]\n): IngestResult {\n return {\n created: results.flatMap((r) => r.created),\n updated: results.flatMap((r) => r.updated),\n unchanged: results.flatMap((r) => r.unchanged),\n };\n}\n","/**\n * @file MemoryClient — primary public API for the memory-layer SDK\n *\n * Pure memory operations: ingest, search, package, list, get, delete,\n * capability inspection, and provider namespace handles. No policy\n * gating, no platform/targetDomain parameters — applications that need\n * those layer them on top of this client.\n */\n\nimport { MemoryService } from '../memory/memory-service';\nimport type { MemoryProvider } from '../memory/provider';\nimport type { AtomicMemoryProviderConfig } from '../memory/atomicmemory-provider/types';\nimport type { AtomicMemoryHandle } from '../memory/atomicmemory-provider/handle';\nimport type { Mem0ProviderConfig } from '../memory/mem0-provider/types';\nimport type { HindsightProviderConfig } from '../memory/hindsight-provider/types';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n Capabilities,\n} from '../memory/types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from '../memory/providers/registry';\n\n/**\n * Provider configuration map. Each key names a provider; the value is\n * that provider's configuration object.\n */\nexport interface MemoryProviderConfigs {\n atomicmemory?: AtomicMemoryProviderConfig;\n mem0?: Mem0ProviderConfig;\n hindsight?: HindsightProviderConfig;\n [providerName: string]: unknown;\n}\n\n/**\n * MemoryClient configuration.\n */\nexport interface MemoryClientConfig {\n /** Provider configurations keyed by provider name. */\n providers: MemoryProviderConfigs;\n /** Name of the default provider. If omitted, the first configured provider wins. */\n defaultProvider?: string;\n}\n\n/**\n * Status summary for each configured provider.\n */\nexport interface ProviderStatus {\n name: string;\n initialized: boolean;\n capabilities: Capabilities | null;\n}\n\n/**\n * MemoryClient — pure memory-layer API.\n *\n * @example\n * ```ts\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hi', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hi', scope: { user: 'u1' } });\n * ```\n */\nexport class MemoryClient {\n private readonly service: MemoryService;\n private initialized = false;\n\n constructor(config: MemoryClientConfig) {\n const providerConfigs: Record<string, unknown> = { ...config.providers };\n const defaultProvider =\n config.defaultProvider ?? pickFirstProviderKey(providerConfigs);\n\n if (!defaultProvider) {\n throw new Error(\n 'MemoryClient requires at least one provider config. ' +\n 'Pass e.g. { providers: { atomicmemory: { apiUrl: \"...\" } } }.'\n );\n }\n\n this.service = new MemoryService({\n defaultProvider,\n providerConfigs,\n });\n }\n\n /**\n * Initialize all configured providers. Must be called before any\n * memory operation. Idempotent.\n */\n async initialize(registry: ProviderRegistry = defaultRegistry): Promise<void> {\n if (this.initialized) return;\n await this.service.initialize(registry);\n this.initialized = true;\n }\n\n /**\n * Write memory(ies). Input supports `text`, `messages`, or `memory` modes.\n */\n async ingest(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Ingest without any application-layer gating. Equivalent to `ingest()`\n * on the core client; application wrappers override the gated variant\n * while delegating this path straight through.\n */\n async ingestDirect(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Search for memories matching the request.\n */\n async search(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Search without application-layer gating. See `ingestDirect` for the\n * rationale.\n */\n async searchDirect(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Build an injection-ready context package from a scoped request.\n * Provider must implement the `package` extension.\n */\n async package(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Package without application-layer gating.\n */\n async packageDirect(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Fetch a single memory by reference.\n */\n async get(ref: MemoryRef): Promise<Memory | null> {\n this.assertInitialized();\n return this.service.get(ref);\n }\n\n /**\n * Delete a single memory by reference.\n */\n async delete(ref: MemoryRef): Promise<void> {\n this.assertInitialized();\n return this.service.delete(ref);\n }\n\n /**\n * List memories within a scope.\n */\n async list(request: ListRequest): Promise<ListResultPage> {\n this.assertInitialized();\n return this.service.list(request);\n }\n\n /**\n * Report the capability surface of the default (or named) provider.\n *\n * @throws if the named provider is unknown or not initialized.\n */\n capabilities(providerName?: string): Capabilities {\n this.assertInitialized();\n return this.service.getProvider(providerName).capabilities();\n }\n\n /**\n * Resolve a named extension on the default (or named) provider.\n * Returns `undefined` when the provider does not advertise the\n * extension.\n *\n * @throws if the named provider is unknown or not initialized.\n *\n * @example\n * ```ts\n * const pkg = memory.getExtension<Packager>('package');\n * ```\n */\n getExtension<T>(extensionName: string, providerName?: string): T | undefined {\n this.assertInitialized();\n const provider = this.service.getProvider(providerName);\n return provider.getExtension?.<T>(extensionName);\n }\n\n /**\n * Aggregate status of all configured providers. Never throws:\n * uninitialized providers report `initialized: false` and\n * `capabilities: null`.\n */\n getProviderStatus(): ProviderStatus[] {\n const configured = this.service.getConfiguredProviders();\n const available = new Set(this.service.getAvailableProviders());\n return configured.map((name) => {\n if (!available.has(name)) {\n return { name, initialized: false, capabilities: null };\n }\n return {\n name,\n initialized: true,\n capabilities: this.service.getProvider(name).capabilities(),\n };\n });\n }\n\n /**\n * Access the full AtomicMemory namespace handle (lifecycle, audit,\n * lessons, config, agents). Returns `undefined` when the client is\n * not yet initialized, the `atomicmemory` provider was not included\n * in the `providers` config, or that provider does not advertise the\n * namespace handle. This getter intentionally never throws — callers\n * can guard with a truthy check and let the handle's own methods\n * raise if used incorrectly.\n */\n get atomicmemory(): AtomicMemoryHandle | undefined {\n if (!this.initialized) return undefined;\n if (!this.service.getConfiguredProviders().includes('atomicmemory')) {\n return undefined;\n }\n const provider = this.service.getProvider('atomicmemory');\n return provider.getExtension?.<AtomicMemoryHandle>('atomicmemory.base');\n }\n\n /**\n * Low-level escape hatch for callers that need the concrete provider.\n */\n getProvider(name?: string): MemoryProvider {\n this.assertInitialized();\n return this.service.getProvider(name);\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'MemoryClient is not initialized. Call `await client.initialize()` first.'\n );\n }\n }\n}\n\nfunction pickFirstProviderKey(providers: Record<string, unknown>): string | undefined {\n for (const [key, value] of Object.entries(providers)) {\n if (value !== undefined && key !== 'default') return key;\n }\n return undefined;\n}\n"]} |
| 'use strict'; | ||
| var chunkGHOB6O5U_cjs = require('./chunk-GHOB6O5U.cjs'); | ||
| // src/memory/providers/registry.ts | ||
| var defaultRegistry = { | ||
| atomicmemory: (config) => ({ | ||
| provider: new chunkGHOB6O5U_cjs.AtomicMemoryProvider(config) | ||
| }), | ||
| mem0: (config) => ({ | ||
| provider: new chunkGHOB6O5U_cjs.Mem0Provider(config) | ||
| }), | ||
| hindsight: (config) => ({ | ||
| provider: new chunkGHOB6O5U_cjs.HindsightProvider(config) | ||
| }) | ||
| }; | ||
| // src/memory/memory-service.ts | ||
| var MemoryService = class { | ||
| constructor(config) { | ||
| this.config = config; | ||
| this.defaultProviderName = config.defaultProvider; | ||
| } | ||
| config; | ||
| providers = /* @__PURE__ */ new Map(); | ||
| pipelines = /* @__PURE__ */ new Map(); | ||
| defaultProviderName; | ||
| async initialize(registry = defaultRegistry) { | ||
| for (const [name, providerConfig] of Object.entries( | ||
| this.config.providerConfigs | ||
| )) { | ||
| const factory = registry[name]; | ||
| if (!factory) continue; | ||
| const registration = factory(providerConfig); | ||
| this.providers.set(name, registration.provider); | ||
| this.pipelines.set( | ||
| name, | ||
| registration.pipeline ?? chunkGHOB6O5U_cjs.noopMemoryPipeline | ||
| ); | ||
| if (registration.provider.initialize) { | ||
| await registration.provider.initialize(); | ||
| } | ||
| } | ||
| } | ||
| getProvider(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| const provider = this.providers.get(providerName); | ||
| if (!provider) { | ||
| throw new Error( | ||
| `Provider "${providerName}" is not registered` | ||
| ); | ||
| } | ||
| return provider; | ||
| } | ||
| getAvailableProviders() { | ||
| return Array.from(this.providers.keys()); | ||
| } | ||
| /** | ||
| * Provider names declared in the SDK configuration, regardless of whether | ||
| * they have been initialized yet. Useful for UI and getter paths that | ||
| * need to advertise capabilities before `initialize()` has run. | ||
| */ | ||
| getConfiguredProviders() { | ||
| return Object.keys(this.config.providerConfigs); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Core operations | ||
| // ----------------------------------------------------------------------- | ||
| async ingest(input, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| if (pipeline.preprocessIngest) { | ||
| const inputs = await pipeline.preprocessIngest(input); | ||
| const results = []; | ||
| for (const i of inputs) { | ||
| const result2 = await provider.ingest(i); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result2, i); | ||
| } | ||
| results.push(result2); | ||
| } | ||
| return mergeIngestResults(results); | ||
| } | ||
| const result = await provider.ingest(input); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result, input); | ||
| } | ||
| return result; | ||
| } | ||
| async search(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRequest = pipeline.preprocessSearch ? await pipeline.preprocessSearch(request) : request; | ||
| const page = await provider.search(processedRequest); | ||
| return pipeline.postprocessSearch ? await pipeline.postprocessSearch(page, processedRequest) : page; | ||
| } | ||
| async get(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRef = pipeline.preprocessGet ? await pipeline.preprocessGet(ref) : ref; | ||
| const memory = await provider.get(processedRef); | ||
| return pipeline.postprocessGet ? await pipeline.postprocessGet(memory, processedRef) : memory; | ||
| } | ||
| async delete(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| await provider.delete(ref); | ||
| } | ||
| async list(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const page = await provider.list(request); | ||
| return pipeline.postprocessList ? await pipeline.postprocessList(page, request) : page; | ||
| } | ||
| async package(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const packager = provider.getExtension?.("package"); | ||
| if (!packager) { | ||
| throw new chunkGHOB6O5U_cjs.UnsupportedOperationError( | ||
| provider.name, | ||
| "package" | ||
| ); | ||
| } | ||
| return packager.package(request); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Internals | ||
| // ----------------------------------------------------------------------- | ||
| getPipeline(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| return this.pipelines.get(providerName) ?? chunkGHOB6O5U_cjs.noopMemoryPipeline; | ||
| } | ||
| }; | ||
| function mergeIngestResults(results) { | ||
| return { | ||
| created: results.flatMap((r) => r.created), | ||
| updated: results.flatMap((r) => r.updated), | ||
| unchanged: results.flatMap((r) => r.unchanged) | ||
| }; | ||
| } | ||
| // src/client/memory-client.ts | ||
| var MemoryClient = class { | ||
| service; | ||
| initialized = false; | ||
| constructor(config) { | ||
| const providerConfigs = { ...config.providers }; | ||
| const defaultProvider = config.defaultProvider ?? pickFirstProviderKey(providerConfigs); | ||
| if (!defaultProvider) { | ||
| throw new Error( | ||
| 'MemoryClient requires at least one provider config. Pass e.g. { providers: { atomicmemory: { apiUrl: "..." } } }.' | ||
| ); | ||
| } | ||
| this.service = new MemoryService({ | ||
| defaultProvider, | ||
| providerConfigs | ||
| }); | ||
| } | ||
| /** | ||
| * Initialize all configured providers. Must be called before any | ||
| * memory operation. Idempotent. | ||
| */ | ||
| async initialize(registry = defaultRegistry) { | ||
| if (this.initialized) return; | ||
| await this.service.initialize(registry); | ||
| this.initialized = true; | ||
| } | ||
| /** | ||
| * Write memory(ies). Input supports `text`, `messages`, or `memory` modes. | ||
| */ | ||
| async ingest(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Ingest without any application-layer gating. Equivalent to `ingest()` | ||
| * on the core client; application wrappers override the gated variant | ||
| * while delegating this path straight through. | ||
| */ | ||
| async ingestDirect(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Search for memories matching the request. | ||
| */ | ||
| async search(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Search without application-layer gating. See `ingestDirect` for the | ||
| * rationale. | ||
| */ | ||
| async searchDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Build an injection-ready context package from a scoped request. | ||
| * Provider must implement the `package` extension. | ||
| */ | ||
| async package(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Package without application-layer gating. | ||
| */ | ||
| async packageDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Fetch a single memory by reference. | ||
| */ | ||
| async get(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.get(ref); | ||
| } | ||
| /** | ||
| * Delete a single memory by reference. | ||
| */ | ||
| async delete(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.delete(ref); | ||
| } | ||
| /** | ||
| * List memories within a scope. | ||
| */ | ||
| async list(request) { | ||
| this.assertInitialized(); | ||
| return this.service.list(request); | ||
| } | ||
| /** | ||
| * Report the capability surface of the default (or named) provider. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| */ | ||
| capabilities(providerName) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(providerName).capabilities(); | ||
| } | ||
| /** | ||
| * Resolve a named extension on the default (or named) provider. | ||
| * Returns `undefined` when the provider does not advertise the | ||
| * extension. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const pkg = memory.getExtension<Packager>('package'); | ||
| * ``` | ||
| */ | ||
| getExtension(extensionName, providerName) { | ||
| this.assertInitialized(); | ||
| const provider = this.service.getProvider(providerName); | ||
| return provider.getExtension?.(extensionName); | ||
| } | ||
| /** | ||
| * Aggregate status of all configured providers. Never throws: | ||
| * uninitialized providers report `initialized: false` and | ||
| * `capabilities: null`. | ||
| */ | ||
| getProviderStatus() { | ||
| const configured = this.service.getConfiguredProviders(); | ||
| const available = new Set(this.service.getAvailableProviders()); | ||
| return configured.map((name) => { | ||
| if (!available.has(name)) { | ||
| return { name, initialized: false, capabilities: null }; | ||
| } | ||
| return { | ||
| name, | ||
| initialized: true, | ||
| capabilities: this.service.getProvider(name).capabilities() | ||
| }; | ||
| }); | ||
| } | ||
| /** | ||
| * Access the full AtomicMemory namespace handle (lifecycle, audit, | ||
| * lessons, config, agents). Returns `undefined` when the client is | ||
| * not yet initialized, the `atomicmemory` provider was not included | ||
| * in the `providers` config, or that provider does not advertise the | ||
| * namespace handle. This getter intentionally never throws — callers | ||
| * can guard with a truthy check and let the handle's own methods | ||
| * raise if used incorrectly. | ||
| */ | ||
| get atomicmemory() { | ||
| if (!this.initialized) return void 0; | ||
| if (!this.service.getConfiguredProviders().includes("atomicmemory")) { | ||
| return void 0; | ||
| } | ||
| const provider = this.service.getProvider("atomicmemory"); | ||
| return provider.getExtension?.("atomicmemory.base"); | ||
| } | ||
| /** | ||
| * Low-level escape hatch for callers that need the concrete provider. | ||
| */ | ||
| getProvider(name) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(name); | ||
| } | ||
| assertInitialized() { | ||
| if (!this.initialized) { | ||
| throw new Error( | ||
| "MemoryClient is not initialized. Call `await client.initialize()` first." | ||
| ); | ||
| } | ||
| } | ||
| }; | ||
| function pickFirstProviderKey(providers) { | ||
| for (const [key, value] of Object.entries(providers)) { | ||
| if (value !== void 0 && key !== "default") return key; | ||
| } | ||
| return void 0; | ||
| } | ||
| exports.MemoryClient = MemoryClient; | ||
| //# sourceMappingURL=chunk-BEZ6NCCC.cjs.map | ||
| //# sourceMappingURL=chunk-BEZ6NCCC.cjs.map |
| {"version":3,"sources":["../src/memory/providers/registry.ts","../src/memory/memory-service.ts","../src/client/memory-client.ts"],"names":["AtomicMemoryProvider","Mem0Provider","HindsightProvider","noopMemoryPipeline","result","UnsupportedOperationError"],"mappings":";;;;;AAoBO,IAAM,eAAA,GAAoC;AAAA,EAC/C,YAAA,EAAc,CAAC,MAAA,MAAoE;AAAA,IACjF,QAAA,EAAU,IAAIA,sCAAA,CAAqB,MAAM;AAAA,GAC3C,CAAA;AAAA,EACA,IAAA,EAAM,CAAC,MAAA,MAA4D;AAAA,IACjE,QAAA,EAAU,IAAIC,8BAAA,CAAa,MAAM;AAAA,GACnC,CAAA;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,MAAiE;AAAA,IAC3E,QAAA,EAAU,IAAIC,mCAAA,CAAkB,MAAM;AAAA,GACxC;AACF,CAAA;;;ACIO,IAAM,gBAAN,MAAoB;AAAA,EAKzB,YAA6B,MAAA,EAA6B;AAA7B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAC3B,IAAA,IAAA,CAAK,sBAAsB,MAAA,CAAO,eAAA;AAAA,EACpC;AAAA,EAF6B,MAAA;AAAA,EAJrB,SAAA,uBAAgB,GAAA,EAA4B;AAAA,EAC5C,SAAA,uBAAgB,GAAA,EAAsC;AAAA,EACtD,mBAAA;AAAA,EAMR,MAAM,UAAA,CACJ,QAAA,GAA6B,eAAA,EACd;AACf,IAAA,KAAA,MAAW,CAAC,IAAA,EAAM,cAAc,CAAA,IAAK,MA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CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpD,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,GAAA,KAAQ,SAAA,EAAW,OAAO,GAAA;AAAA,EACvD;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-BEZ6NCCC.cjs","sourcesContent":["/**\n * @file Memory Provider Registry\n *\n * Maps provider names to factory functions that create\n * MemoryProviderRegistration instances from configuration.\n */\n\nimport type { MemoryProviderRegistration } from '../registration';\nimport type { AtomicMemoryProviderConfig } from '../atomicmemory-provider/types';\nimport { AtomicMemoryProvider } from '../atomicmemory-provider/atomicmemory-provider';\nimport type { Mem0ProviderConfig } from '../mem0-provider/types';\nimport { Mem0Provider } from '../mem0-provider/mem0-provider';\nimport type { HindsightProviderConfig } from '../hindsight-provider/types';\nimport { HindsightProvider } from '../hindsight-provider/hindsight-provider';\n\nexport type ProviderRegistry = Record<\n string,\n (config: any) => MemoryProviderRegistration\n>;\n\nexport const defaultRegistry: ProviderRegistry = {\n atomicmemory: (config: AtomicMemoryProviderConfig): MemoryProviderRegistration => ({\n provider: new AtomicMemoryProvider(config),\n }),\n mem0: (config: Mem0ProviderConfig): MemoryProviderRegistration => ({\n provider: new Mem0Provider(config),\n }),\n hindsight: (config: HindsightProviderConfig): MemoryProviderRegistration => ({\n provider: new HindsightProvider(config),\n }),\n};\n","/**\n * @file Memory Service\n *\n * Replaces UnifiedContextService. Routes operations to the correct\n * provider and applies optional processing pipelines.\n */\n\nimport type { MemoryProvider, Packager } from './provider';\nimport type { MemoryProcessingPipeline } from './pipeline';\nimport { noopMemoryPipeline } from './pipeline';\nimport type { MemoryProviderRegistration } from './registration';\nimport { UnsupportedOperationError } from './errors';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n} from './types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from './providers/registry';\n\nexport interface MemoryServiceConfig {\n defaultProvider: string;\n providerConfigs: Record<string, unknown>;\n}\n\nexport class MemoryService {\n private providers = new Map<string, MemoryProvider>();\n private pipelines = new Map<string, MemoryProcessingPipeline>();\n private defaultProviderName: string;\n\n constructor(private readonly config: MemoryServiceConfig) {\n this.defaultProviderName = config.defaultProvider;\n }\n\n async initialize(\n registry: ProviderRegistry = defaultRegistry\n ): Promise<void> {\n for (const [name, providerConfig] of Object.entries(\n this.config.providerConfigs\n )) {\n const factory = registry[name];\n if (!factory) continue;\n const registration: MemoryProviderRegistration = factory(providerConfig);\n this.providers.set(name, registration.provider);\n this.pipelines.set(\n name,\n registration.pipeline ?? noopMemoryPipeline\n );\n\n if (registration.provider.initialize) {\n await registration.provider.initialize();\n }\n }\n }\n\n getProvider(name?: string): MemoryProvider {\n const providerName = name ?? this.defaultProviderName;\n const provider = this.providers.get(providerName);\n if (!provider) {\n throw new Error(\n `Provider \"${providerName}\" is not registered`\n );\n }\n return provider;\n }\n\n getAvailableProviders(): string[] {\n return Array.from(this.providers.keys());\n }\n\n /**\n * Provider names declared in the SDK configuration, regardless of whether\n * they have been initialized yet. Useful for UI and getter paths that\n * need to advertise capabilities before `initialize()` has run.\n */\n getConfiguredProviders(): string[] {\n return Object.keys(this.config.providerConfigs);\n }\n\n // -----------------------------------------------------------------------\n // Core operations\n // -----------------------------------------------------------------------\n\n async ingest(\n input: IngestInput,\n providerName?: string\n ): Promise<IngestResult> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n if (pipeline.preprocessIngest) {\n const inputs = await pipeline.preprocessIngest(input);\n const results: IngestResult[] = [];\n for (const i of inputs) {\n const result = await provider.ingest(i);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, i);\n }\n results.push(result);\n }\n return mergeIngestResults(results);\n }\n\n const result = await provider.ingest(input);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, input);\n }\n return result;\n }\n\n async search(\n request: SearchRequest,\n providerName?: string\n ): Promise<SearchResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRequest = pipeline.preprocessSearch\n ? await pipeline.preprocessSearch(request)\n : request;\n\n const page = await provider.search(processedRequest);\n\n return pipeline.postprocessSearch\n ? await pipeline.postprocessSearch(page, processedRequest)\n : page;\n }\n\n async get(\n ref: MemoryRef,\n providerName?: string\n ): Promise<Memory | null> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRef = pipeline.preprocessGet\n ? await pipeline.preprocessGet(ref)\n : ref;\n\n const memory = await provider.get(processedRef);\n\n return pipeline.postprocessGet\n ? await pipeline.postprocessGet(memory, processedRef)\n : memory;\n }\n\n async delete(\n ref: MemoryRef,\n providerName?: string\n ): Promise<void> {\n const provider = this.getProvider(providerName);\n await provider.delete(ref);\n }\n\n async list(\n request: ListRequest,\n providerName?: string\n ): Promise<ListResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const page = await provider.list(request);\n\n return pipeline.postprocessList\n ? await pipeline.postprocessList(page, request)\n : page;\n }\n\n async package(\n request: PackageRequest,\n providerName?: string\n ): Promise<ContextPackage> {\n const provider = this.getProvider(providerName);\n const packager = provider.getExtension?.<Packager>('package');\n if (!packager) {\n throw new UnsupportedOperationError(\n provider.name,\n 'package'\n );\n }\n return packager.package(request);\n }\n\n // -----------------------------------------------------------------------\n // Internals\n // -----------------------------------------------------------------------\n\n private getPipeline(\n name?: string\n ): MemoryProcessingPipeline {\n const providerName = name ?? this.defaultProviderName;\n return (\n this.pipelines.get(providerName) ?? noopMemoryPipeline\n );\n }\n}\n\nfunction mergeIngestResults(\n results: IngestResult[]\n): IngestResult {\n return {\n created: results.flatMap((r) => r.created),\n updated: results.flatMap((r) => r.updated),\n unchanged: results.flatMap((r) => r.unchanged),\n };\n}\n","/**\n * @file MemoryClient — primary public API for the memory-layer SDK\n *\n * Pure memory operations: ingest, search, package, list, get, delete,\n * capability inspection, and provider namespace handles. No policy\n * gating, no platform/targetDomain parameters — applications that need\n * those layer them on top of this client.\n */\n\nimport { MemoryService } from '../memory/memory-service';\nimport type { MemoryProvider } from '../memory/provider';\nimport type { AtomicMemoryProviderConfig } from '../memory/atomicmemory-provider/types';\nimport type { AtomicMemoryHandle } from '../memory/atomicmemory-provider/handle';\nimport type { Mem0ProviderConfig } from '../memory/mem0-provider/types';\nimport type { HindsightProviderConfig } from '../memory/hindsight-provider/types';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n Capabilities,\n} from '../memory/types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from '../memory/providers/registry';\n\n/**\n * Provider configuration map. Each key names a provider; the value is\n * that provider's configuration object.\n */\nexport interface MemoryProviderConfigs {\n atomicmemory?: AtomicMemoryProviderConfig;\n mem0?: Mem0ProviderConfig;\n hindsight?: HindsightProviderConfig;\n [providerName: string]: unknown;\n}\n\n/**\n * MemoryClient configuration.\n */\nexport interface MemoryClientConfig {\n /** Provider configurations keyed by provider name. */\n providers: MemoryProviderConfigs;\n /** Name of the default provider. If omitted, the first configured provider wins. */\n defaultProvider?: string;\n}\n\n/**\n * Status summary for each configured provider.\n */\nexport interface ProviderStatus {\n name: string;\n initialized: boolean;\n capabilities: Capabilities | null;\n}\n\n/**\n * MemoryClient — pure memory-layer API.\n *\n * @example\n * ```ts\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hi', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hi', scope: { user: 'u1' } });\n * ```\n */\nexport class MemoryClient {\n private readonly service: MemoryService;\n private initialized = false;\n\n constructor(config: MemoryClientConfig) {\n const providerConfigs: Record<string, unknown> = { ...config.providers };\n const defaultProvider =\n config.defaultProvider ?? pickFirstProviderKey(providerConfigs);\n\n if (!defaultProvider) {\n throw new Error(\n 'MemoryClient requires at least one provider config. ' +\n 'Pass e.g. { providers: { atomicmemory: { apiUrl: \"...\" } } }.'\n );\n }\n\n this.service = new MemoryService({\n defaultProvider,\n providerConfigs,\n });\n }\n\n /**\n * Initialize all configured providers. Must be called before any\n * memory operation. Idempotent.\n */\n async initialize(registry: ProviderRegistry = defaultRegistry): Promise<void> {\n if (this.initialized) return;\n await this.service.initialize(registry);\n this.initialized = true;\n }\n\n /**\n * Write memory(ies). Input supports `text`, `messages`, or `memory` modes.\n */\n async ingest(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Ingest without any application-layer gating. Equivalent to `ingest()`\n * on the core client; application wrappers override the gated variant\n * while delegating this path straight through.\n */\n async ingestDirect(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Search for memories matching the request.\n */\n async search(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Search without application-layer gating. See `ingestDirect` for the\n * rationale.\n */\n async searchDirect(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Build an injection-ready context package from a scoped request.\n * Provider must implement the `package` extension.\n */\n async package(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Package without application-layer gating.\n */\n async packageDirect(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Fetch a single memory by reference.\n */\n async get(ref: MemoryRef): Promise<Memory | null> {\n this.assertInitialized();\n return this.service.get(ref);\n }\n\n /**\n * Delete a single memory by reference.\n */\n async delete(ref: MemoryRef): Promise<void> {\n this.assertInitialized();\n return this.service.delete(ref);\n }\n\n /**\n * List memories within a scope.\n */\n async list(request: ListRequest): Promise<ListResultPage> {\n this.assertInitialized();\n return this.service.list(request);\n }\n\n /**\n * Report the capability surface of the default (or named) provider.\n *\n * @throws if the named provider is unknown or not initialized.\n */\n capabilities(providerName?: string): Capabilities {\n this.assertInitialized();\n return this.service.getProvider(providerName).capabilities();\n }\n\n /**\n * Resolve a named extension on the default (or named) provider.\n * Returns `undefined` when the provider does not advertise the\n * extension.\n *\n * @throws if the named provider is unknown or not initialized.\n *\n * @example\n * ```ts\n * const pkg = memory.getExtension<Packager>('package');\n * ```\n */\n getExtension<T>(extensionName: string, providerName?: string): T | undefined {\n this.assertInitialized();\n const provider = this.service.getProvider(providerName);\n return provider.getExtension?.<T>(extensionName);\n }\n\n /**\n * Aggregate status of all configured providers. Never throws:\n * uninitialized providers report `initialized: false` and\n * `capabilities: null`.\n */\n getProviderStatus(): ProviderStatus[] {\n const configured = this.service.getConfiguredProviders();\n const available = new Set(this.service.getAvailableProviders());\n return configured.map((name) => {\n if (!available.has(name)) {\n return { name, initialized: false, capabilities: null };\n }\n return {\n name,\n initialized: true,\n capabilities: this.service.getProvider(name).capabilities(),\n };\n });\n }\n\n /**\n * Access the full AtomicMemory namespace handle (lifecycle, audit,\n * lessons, config, agents). Returns `undefined` when the client is\n * not yet initialized, the `atomicmemory` provider was not included\n * in the `providers` config, or that provider does not advertise the\n * namespace handle. This getter intentionally never throws — callers\n * can guard with a truthy check and let the handle's own methods\n * raise if used incorrectly.\n */\n get atomicmemory(): AtomicMemoryHandle | undefined {\n if (!this.initialized) return undefined;\n if (!this.service.getConfiguredProviders().includes('atomicmemory')) {\n return undefined;\n }\n const provider = this.service.getProvider('atomicmemory');\n return provider.getExtension?.<AtomicMemoryHandle>('atomicmemory.base');\n }\n\n /**\n * Low-level escape hatch for callers that need the concrete provider.\n */\n getProvider(name?: string): MemoryProvider {\n this.assertInitialized();\n return this.service.getProvider(name);\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'MemoryClient is not initialized. Call `await client.initialize()` first.'\n );\n }\n }\n}\n\nfunction pickFirstProviderKey(providers: Record<string, unknown>): string | undefined {\n for (const [key, value] of Object.entries(providers)) {\n if (value !== undefined && key !== 'default') return key;\n }\n return undefined;\n}\n"]} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
+22
-22
| 'use strict'; | ||
| var chunkGSRHENFD_cjs = require('./chunk-GSRHENFD.cjs'); | ||
| var chunkIK2P4INW_cjs = require('./chunk-IK2P4INW.cjs'); | ||
| var chunkBEZ6NCCC_cjs = require('./chunk-BEZ6NCCC.cjs'); | ||
| var chunkGHOB6O5U_cjs = require('./chunk-GHOB6O5U.cjs'); | ||
@@ -10,81 +10,81 @@ | ||
| enumerable: true, | ||
| get: function () { return chunkGSRHENFD_cjs.MemoryClient; } | ||
| get: function () { return chunkBEZ6NCCC_cjs.MemoryClient; } | ||
| }); | ||
| Object.defineProperty(exports, "ATOMICMEMORY_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "ATOMICMEMORY_EXTENSION_NAMES", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| }); | ||
| Object.defineProperty(exports, "AtomicMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.AtomicMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.AtomicMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "BaseMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.BaseMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.BaseMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_API_VERSION", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_MAX_TOKENS", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_PROJECT_ID", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_SCOPE_TAGS_MATCH", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| }); | ||
| Object.defineProperty(exports, "HindsightProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HindsightProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HindsightProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "InvalidScopeError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.InvalidScopeError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.InvalidScopeError; } | ||
| }); | ||
| Object.defineProperty(exports, "MEM0_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0ContextProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0ContextProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0ContextProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0Provider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0Provider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0Provider; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryProviderError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryProviderError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryProviderError; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryTransportError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryTransportError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryTransportError; } | ||
| }); | ||
| Object.defineProperty(exports, "RateLimitError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.RateLimitError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.RateLimitError; } | ||
| }); | ||
| Object.defineProperty(exports, "UnsupportedOperationError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.UnsupportedOperationError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.UnsupportedOperationError; } | ||
| }); | ||
| Object.defineProperty(exports, "noopMemoryPipeline", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.noopMemoryPipeline; } | ||
| get: function () { return chunkGHOB6O5U_cjs.noopMemoryPipeline; } | ||
| }); | ||
| //# sourceMappingURL=browser.cjs.map | ||
| //# sourceMappingURL=browser.cjs.map |
@@ -55,3 +55,3 @@ import { MemoryProviderRegistration, AtomicMemoryProviderConfig, Mem0ProviderConfig, HindsightProviderConfig, IngestInput, IngestResult, SearchRequest, SearchResultPage, PackageRequest, ContextPackage, MemoryRef, Memory, ListRequest, ListResultPage, Capabilities, AtomicMemoryHandle, MemoryProvider } from './memory.cjs'; | ||
| * const memory = new MemoryClient({ | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } }, | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } }, | ||
| * }); | ||
@@ -58,0 +58,0 @@ * await memory.initialize(); |
@@ -55,3 +55,3 @@ import { MemoryProviderRegistration, AtomicMemoryProviderConfig, Mem0ProviderConfig, HindsightProviderConfig, IngestInput, IngestResult, SearchRequest, SearchResultPage, PackageRequest, ContextPackage, MemoryRef, Memory, ListRequest, ListResultPage, Capabilities, AtomicMemoryHandle, MemoryProvider } from './memory.js'; | ||
| * const memory = new MemoryClient({ | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } }, | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } }, | ||
| * }); | ||
@@ -58,0 +58,0 @@ * await memory.initialize(); |
+2
-2
@@ -1,4 +0,4 @@ | ||
| export { MemoryClient } from './chunk-4ZK445ML.js'; | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, noopMemoryPipeline } from './chunk-75KDUWRG.js'; | ||
| export { MemoryClient } from './chunk-265G225P.js'; | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, noopMemoryPipeline } from './chunk-YBN5Y627.js'; | ||
| //# sourceMappingURL=browser.js.map | ||
| //# sourceMappingURL=browser.js.map |
+23
-23
| 'use strict'; | ||
| var chunkGSRHENFD_cjs = require('./chunk-GSRHENFD.cjs'); | ||
| var chunkIK2P4INW_cjs = require('./chunk-IK2P4INW.cjs'); | ||
| var chunkBEZ6NCCC_cjs = require('./chunk-BEZ6NCCC.cjs'); | ||
| var chunkGHOB6O5U_cjs = require('./chunk-GHOB6O5U.cjs'); | ||
| var chunkH52DPNS2_cjs = require('./chunk-H52DPNS2.cjs'); | ||
@@ -31,3 +31,3 @@ var chunkDIZ6Y5IO_cjs = require('./chunk-DIZ6Y5IO.cjs'); | ||
| } | ||
| this.memory = new chunkGSRHENFD_cjs.MemoryClient( | ||
| this.memory = new chunkBEZ6NCCC_cjs.MemoryClient( | ||
| config.memory ?? { | ||
@@ -54,79 +54,79 @@ providers: { | ||
| enumerable: true, | ||
| get: function () { return chunkGSRHENFD_cjs.MemoryClient; } | ||
| get: function () { return chunkBEZ6NCCC_cjs.MemoryClient; } | ||
| }); | ||
| Object.defineProperty(exports, "ATOMICMEMORY_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "ATOMICMEMORY_EXTENSION_NAMES", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| }); | ||
| Object.defineProperty(exports, "AtomicMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.AtomicMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.AtomicMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "BaseMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.BaseMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.BaseMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_API_VERSION", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_MAX_TOKENS", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_PROJECT_ID", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_SCOPE_TAGS_MATCH", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| }); | ||
| Object.defineProperty(exports, "HindsightProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HindsightProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HindsightProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "InvalidScopeError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.InvalidScopeError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.InvalidScopeError; } | ||
| }); | ||
| Object.defineProperty(exports, "MEM0_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0ContextProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0ContextProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0ContextProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0Provider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0Provider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0Provider; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryProviderError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryProviderError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryProviderError; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryTransportError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryTransportError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryTransportError; } | ||
| }); | ||
| Object.defineProperty(exports, "RateLimitError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.RateLimitError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.RateLimitError; } | ||
| }); | ||
| Object.defineProperty(exports, "UnsupportedOperationError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.UnsupportedOperationError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.UnsupportedOperationError; } | ||
| }); | ||
| Object.defineProperty(exports, "noopMemoryPipeline", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.noopMemoryPipeline; } | ||
| get: function () { return chunkGHOB6O5U_cjs.noopMemoryPipeline; } | ||
| }); | ||
@@ -133,0 +133,0 @@ Object.defineProperty(exports, "DEFAULT_VALIDATION_CONFIG", { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/client/atomic-memory-client.ts","../src/index.ts"],"names":["MemoryClient","ConcreteStorageClient"],"mappings":";;;;;;;;;;;;;;;;;AA4DO,IAAM,qBAAN,MAAyB;AAAA,EACrB,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,MAAA,EAAkC;AAC5C,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AAOA,IAAA,IAAA,CAAK,SAAS,IAAIA,8BAAA;AAAA,MAChB,OAAO,MAAA,IAAU;AAAA,QACf,SAAA,EAAW;AAAA,UACT,cAAc,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA;AAAO;AAC/D;AACF,KACF;AACA,IAAA,IAAA,CAAK,OAAA,GAAU,IAAIC,uCAAA,CAAsB;AAAA,MACvC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,OAAO,MAAA,CAAO;AAAA,KACf,CAAA;AAAA,EACH;AACF;;;ACsDO,IAAM,WAAA,GAAc;AACpB,IAAM,WAAA,GAAc","file":"index.cjs","sourcesContent":["/**\n * @file `AtomicMemoryClient` — primary public surface for the SDK.\n *\n * Aggregates `memory` (the memory-layer API) and `storage` (the\n * direct-storage API) under one client so callers see a coherent\n * single entry point:\n *\n * import { AtomicMemoryClient } from '@atomicmemory/sdk';\n * const client = new AtomicMemoryClient({\n * apiUrl: 'http://localhost:3050',\n * apiKey: process.env.ATOMICMEMORY_API_KEY!,\n * userId: 'u1',\n * });\n * await client.memory.initialize();\n * const artifact = await client.storage.put({\n * mode: 'pointer',\n * uri: 'https://example.com/file.pdf',\n * contentType: 'application/pdf',\n * });\n *\n * v1 SDK is server-side only. Browser bundles must proxy through a\n * trusted server, such as an application-owned API boundary.\n *\n * Applications that only need memory operations can still use\n * `MemoryClient` directly. New integrations should prefer\n * `AtomicMemoryClient.memory`.\n */\n\nimport { MemoryClient, type MemoryClientConfig } from './memory-client';\nimport { ConcreteStorageClient } from '../storage/client';\nimport type { StorageClient } from '../storage/interfaces';\n\n/**\n * Constructor config for the aggregator. All three transport fields\n * (`apiUrl`, `apiKey`, `userId`) are REQUIRED — they back both the\n * storage namespace and the default AtomicMemory memory provider.\n * Memory-only consumers should still pass `apiUrl` (it doubles as\n * the default memory provider's `apiUrl`); the `memory` block then\n * narrows the registration further if a non-default provider mix is\n * needed.\n *\n * `userId` is the owner-scope seam the storage routes accept until a\n * real auth seam ships. `fetch` is an optional override; defaults to\n * the Node global.\n */\nexport interface AtomicMemoryClientConfig {\n apiUrl: string;\n apiKey: string;\n userId: string;\n /** Optional fetch override — defaults to the Node global. */\n fetch?: typeof fetch;\n /** Memory-provider registration. Defaults to a single AtomicMemory\n * provider pointing at `apiUrl`. */\n memory?: MemoryClientConfig;\n}\n\n/**\n * Primary public client. Holds a `memory` namespace (`MemoryClient`)\n * and a `storage` namespace (`StorageClient`).\n */\nexport class AtomicMemoryClient {\n readonly memory: MemoryClient;\n readonly storage: StorageClient;\n\n constructor(config: AtomicMemoryClientConfig) {\n if (!config.apiUrl) {\n throw new Error('AtomicMemoryClient: apiUrl is required');\n }\n if (!config.apiKey) {\n throw new Error('AtomicMemoryClient: apiKey is required');\n }\n if (!config.userId) {\n throw new Error('AtomicMemoryClient: userId is required');\n }\n // Default provider registration MUST forward the apiKey so the\n // memory namespace shares the storage namespace's auth contract.\n // The earlier shape dropped it silently — memory requests went\n // out unauthenticated even when the caller supplied `apiKey`,\n // failing with 401 against any core deployment that gates `/v1/*`\n // (every deployment since the auth middleware landed).\n this.memory = new MemoryClient(\n config.memory ?? {\n providers: {\n atomicmemory: { apiUrl: config.apiUrl, apiKey: config.apiKey },\n },\n },\n );\n this.storage = new ConcreteStorageClient({\n apiUrl: config.apiUrl,\n apiKey: config.apiKey,\n userId: config.userId,\n fetch: config.fetch,\n });\n }\n}\n","/**\n * @file @atomicmemory/sdk public surface\n *\n * Backend-agnostic memory-layer SDK. Pluggable providers, local\n * embeddings, storage adapters, semantic search.\n *\n * @example\n * ```typescript\n * import { MemoryClient } from '@atomicmemory/sdk';\n *\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hello', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hello', scope: { user: 'u1' } });\n * ```\n */\n\n// Primary client — `AtomicMemoryClient` aggregates the memory and\n// storage namespaces. `MemoryClient` remains available for\n// applications that only need memory operations.\nexport {\n AtomicMemoryClient,\n type AtomicMemoryClientConfig,\n} from './client/atomic-memory-client';\n\nexport { MemoryClient } from './client/memory-client';\nexport type {\n MemoryClientConfig,\n MemoryProviderConfigs,\n ProviderStatus,\n} from './client/memory-client';\n\n// Types\nexport * from './types';\n\n// Event system\nexport { EventEmitter, type EventMap } from './core/events';\n\n// Error handling\nexport {\n AtomicMemoryError,\n StorageError,\n EmbeddingError,\n SearchError,\n ConfigurationError,\n NetworkError,\n RetryableOperation,\n withRetry,\n ErrorContext,\n ErrorUtils,\n type RetryPolicy,\n} from './core/error-handling/';\n\n// KV cache used by embeddings and local search. New artifact-storage\n// integrations should use the `./storage` subpath.\nexport { StorageManager } from './kv-cache/storage-manager';\nexport { MemoryStorageAdapter } from './kv-cache/memory-storage';\nexport { IndexedDBStorageAdapter } from './kv-cache/indexeddb-storage';\nexport type { StorageAdapter, StorageStats } from './kv-cache/storage-adapter';\n\n// KV cache validation\nexport {\n StorageValidator,\n validateKey,\n validateValue,\n validateKeyValue,\n assertValidKey,\n assertValidValue,\n assertValidKeyValue,\n DEFAULT_VALIDATION_CONFIG,\n} from './kv-cache/validation';\nexport type { ValidationConfig, ValidationResult } from './kv-cache/validation';\n\n// Storage API for the public `client.storage` namespace.\nexport * from './storage';\n\n// Logging\nexport {\n Logger,\n getLogger,\n configureLogging,\n setLogLevel,\n logger,\n} from './utils/logger';\nexport type {\n LogLevel,\n LogContext,\n LogEntry,\n LoggerConfig,\n} from './utils/logger';\n\n// Debug logging\nexport {\n setDebugHandler,\n setDebugEnabled,\n isDebugEnabled,\n debugLog,\n debugInfo,\n debugWarn,\n debugError,\n} from './utils/debug-logger';\nexport type { DebugLogEntry, DebugLogHandler } from './utils/debug-logger';\n\n// Embedding\nexport { EmbeddingGenerator } from './embedding/embedding-generator';\nexport { TransformersAdapter } from './embedding/transformers-adapter';\nexport { WasmSemanticProcessor } from './embedding/wasm-semantic-processor';\nexport { testWebAssemblySupport } from './embedding/wasm-semantic-processor';\n\n// Search\nexport { SemanticSearch } from './search/semantic-search';\nexport { cosineSimilarity } from './search/similarity-calculator';\nexport type {\n SemanticSearchResult,\n SearchOptions,\n StoredContext,\n} from './search/semantic-search/types';\n\n// Utilities\nexport { PerformanceMonitor } from './utils/performance';\nexport { DebugTools } from './utils/debugging';\nexport * from './utils/validation';\nexport {\n getEnvironment,\n isTestEnvironment,\n isDevelopmentEnvironment,\n isExtensionEnvironment,\n} from './utils/environment';\n\n// Runtime configuration — singleton consumed by application wrappers\n// that need to initialize environment settings at SDK startup.\nexport { RuntimeConfig, runtimeConfig } from './core/runtime-config';\n\n// Memory system — types, provider interface, concrete adapters.\n// `MemoryService` is intentionally not re-exported from root; consumers\n// use `MemoryClient` (above) as the canonical API.\nexport * from './memory/types';\nexport * from './memory/errors';\nexport * from './memory/provider';\nexport * from './memory/pipeline';\nexport * from './memory/registration';\nexport * from './memory/atomicmemory-provider';\nexport * from './memory/mem0-provider';\nexport * from './memory/hindsight-provider';\n\n// Version information\nexport const SDK_VERSION = '1.0.0';\nexport const API_VERSION = '1.0';\n"]} | ||
| {"version":3,"sources":["../src/client/atomic-memory-client.ts","../src/index.ts"],"names":["MemoryClient","ConcreteStorageClient"],"mappings":";;;;;;;;;;;;;;;;;AA4DO,IAAM,qBAAN,MAAyB;AAAA,EACrB,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,MAAA,EAAkC;AAC5C,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AAOA,IAAA,IAAA,CAAK,SAAS,IAAIA,8BAAA;AAAA,MAChB,OAAO,MAAA,IAAU;AAAA,QACf,SAAA,EAAW;AAAA,UACT,cAAc,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA;AAAO;AAC/D;AACF,KACF;AACA,IAAA,IAAA,CAAK,OAAA,GAAU,IAAIC,uCAAA,CAAsB;AAAA,MACvC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,OAAO,MAAA,CAAO;AAAA,KACf,CAAA;AAAA,EACH;AACF;;;ACsDO,IAAM,WAAA,GAAc;AACpB,IAAM,WAAA,GAAc","file":"index.cjs","sourcesContent":["/**\n * @file `AtomicMemoryClient` — primary public surface for the SDK.\n *\n * Aggregates `memory` (the memory-layer API) and `storage` (the\n * direct-storage API) under one client so callers see a coherent\n * single entry point:\n *\n * import { AtomicMemoryClient } from '@atomicmemory/sdk';\n * const client = new AtomicMemoryClient({\n * apiUrl: 'http://localhost:17350',\n * apiKey: process.env.ATOMICMEMORY_API_KEY!,\n * userId: 'u1',\n * });\n * await client.memory.initialize();\n * const artifact = await client.storage.put({\n * mode: 'pointer',\n * uri: 'https://example.com/file.pdf',\n * contentType: 'application/pdf',\n * });\n *\n * v1 SDK is server-side only. Browser bundles must proxy through a\n * trusted server, such as an application-owned API boundary.\n *\n * Applications that only need memory operations can still use\n * `MemoryClient` directly. New integrations should prefer\n * `AtomicMemoryClient.memory`.\n */\n\nimport { MemoryClient, type MemoryClientConfig } from './memory-client';\nimport { ConcreteStorageClient } from '../storage/client';\nimport type { StorageClient } from '../storage/interfaces';\n\n/**\n * Constructor config for the aggregator. All three transport fields\n * (`apiUrl`, `apiKey`, `userId`) are REQUIRED — they back both the\n * storage namespace and the default AtomicMemory memory provider.\n * Memory-only consumers should still pass `apiUrl` (it doubles as\n * the default memory provider's `apiUrl`); the `memory` block then\n * narrows the registration further if a non-default provider mix is\n * needed.\n *\n * `userId` is the owner-scope seam the storage routes accept until a\n * real auth seam ships. `fetch` is an optional override; defaults to\n * the Node global.\n */\nexport interface AtomicMemoryClientConfig {\n apiUrl: string;\n apiKey: string;\n userId: string;\n /** Optional fetch override — defaults to the Node global. */\n fetch?: typeof fetch;\n /** Memory-provider registration. Defaults to a single AtomicMemory\n * provider pointing at `apiUrl`. */\n memory?: MemoryClientConfig;\n}\n\n/**\n * Primary public client. Holds a `memory` namespace (`MemoryClient`)\n * and a `storage` namespace (`StorageClient`).\n */\nexport class AtomicMemoryClient {\n readonly memory: MemoryClient;\n readonly storage: StorageClient;\n\n constructor(config: AtomicMemoryClientConfig) {\n if (!config.apiUrl) {\n throw new Error('AtomicMemoryClient: apiUrl is required');\n }\n if (!config.apiKey) {\n throw new Error('AtomicMemoryClient: apiKey is required');\n }\n if (!config.userId) {\n throw new Error('AtomicMemoryClient: userId is required');\n }\n // Default provider registration MUST forward the apiKey so the\n // memory namespace shares the storage namespace's auth contract.\n // The earlier shape dropped it silently — memory requests went\n // out unauthenticated even when the caller supplied `apiKey`,\n // failing with 401 against any core deployment that gates `/v1/*`\n // (every deployment since the auth middleware landed).\n this.memory = new MemoryClient(\n config.memory ?? {\n providers: {\n atomicmemory: { apiUrl: config.apiUrl, apiKey: config.apiKey },\n },\n },\n );\n this.storage = new ConcreteStorageClient({\n apiUrl: config.apiUrl,\n apiKey: config.apiKey,\n userId: config.userId,\n fetch: config.fetch,\n });\n }\n}\n","/**\n * @file @atomicmemory/sdk public surface\n *\n * Backend-agnostic memory-layer SDK. Pluggable providers, local\n * embeddings, storage adapters, semantic search.\n *\n * @example\n * ```typescript\n * import { MemoryClient } from '@atomicmemory/sdk';\n *\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hello', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hello', scope: { user: 'u1' } });\n * ```\n */\n\n// Primary client — `AtomicMemoryClient` aggregates the memory and\n// storage namespaces. `MemoryClient` remains available for\n// applications that only need memory operations.\nexport {\n AtomicMemoryClient,\n type AtomicMemoryClientConfig,\n} from './client/atomic-memory-client';\n\nexport { MemoryClient } from './client/memory-client';\nexport type {\n MemoryClientConfig,\n MemoryProviderConfigs,\n ProviderStatus,\n} from './client/memory-client';\n\n// Types\nexport * from './types';\n\n// Event system\nexport { EventEmitter, type EventMap } from './core/events';\n\n// Error handling\nexport {\n AtomicMemoryError,\n StorageError,\n EmbeddingError,\n SearchError,\n ConfigurationError,\n NetworkError,\n RetryableOperation,\n withRetry,\n ErrorContext,\n ErrorUtils,\n type RetryPolicy,\n} from './core/error-handling/';\n\n// KV cache used by embeddings and local search. New artifact-storage\n// integrations should use the `./storage` subpath.\nexport { StorageManager } from './kv-cache/storage-manager';\nexport { MemoryStorageAdapter } from './kv-cache/memory-storage';\nexport { IndexedDBStorageAdapter } from './kv-cache/indexeddb-storage';\nexport type { StorageAdapter, StorageStats } from './kv-cache/storage-adapter';\n\n// KV cache validation\nexport {\n StorageValidator,\n validateKey,\n validateValue,\n validateKeyValue,\n assertValidKey,\n assertValidValue,\n assertValidKeyValue,\n DEFAULT_VALIDATION_CONFIG,\n} from './kv-cache/validation';\nexport type { ValidationConfig, ValidationResult } from './kv-cache/validation';\n\n// Storage API for the public `client.storage` namespace.\nexport * from './storage';\n\n// Logging\nexport {\n Logger,\n getLogger,\n configureLogging,\n setLogLevel,\n logger,\n} from './utils/logger';\nexport type {\n LogLevel,\n LogContext,\n LogEntry,\n LoggerConfig,\n} from './utils/logger';\n\n// Debug logging\nexport {\n setDebugHandler,\n setDebugEnabled,\n isDebugEnabled,\n debugLog,\n debugInfo,\n debugWarn,\n debugError,\n} from './utils/debug-logger';\nexport type { DebugLogEntry, DebugLogHandler } from './utils/debug-logger';\n\n// Embedding\nexport { EmbeddingGenerator } from './embedding/embedding-generator';\nexport { TransformersAdapter } from './embedding/transformers-adapter';\nexport { WasmSemanticProcessor } from './embedding/wasm-semantic-processor';\nexport { testWebAssemblySupport } from './embedding/wasm-semantic-processor';\n\n// Search\nexport { SemanticSearch } from './search/semantic-search';\nexport { cosineSimilarity } from './search/similarity-calculator';\nexport type {\n SemanticSearchResult,\n SearchOptions,\n StoredContext,\n} from './search/semantic-search/types';\n\n// Utilities\nexport { PerformanceMonitor } from './utils/performance';\nexport { DebugTools } from './utils/debugging';\nexport * from './utils/validation';\nexport {\n getEnvironment,\n isTestEnvironment,\n isDevelopmentEnvironment,\n isExtensionEnvironment,\n} from './utils/environment';\n\n// Runtime configuration — singleton consumed by application wrappers\n// that need to initialize environment settings at SDK startup.\nexport { RuntimeConfig, runtimeConfig } from './core/runtime-config';\n\n// Memory system — types, provider interface, concrete adapters.\n// `MemoryService` is intentionally not re-exported from root; consumers\n// use `MemoryClient` (above) as the canonical API.\nexport * from './memory/types';\nexport * from './memory/errors';\nexport * from './memory/provider';\nexport * from './memory/pipeline';\nexport * from './memory/registration';\nexport * from './memory/atomicmemory-provider';\nexport * from './memory/mem0-provider';\nexport * from './memory/hindsight-provider';\n\n// Version information\nexport const SDK_VERSION = '1.0.0';\nexport const API_VERSION = '1.0';\n"]} |
+2
-2
@@ -24,3 +24,3 @@ import { MemoryClient, MemoryClientConfig } from './browser.cjs'; | ||
| * const client = new AtomicMemoryClient({ | ||
| * apiUrl: 'http://localhost:3050', | ||
| * apiUrl: 'http://localhost:17350', | ||
| * apiKey: process.env.ATOMICMEMORY_API_KEY!, | ||
@@ -274,3 +274,3 @@ * userId: 'u1', | ||
| * const memory = new MemoryClient({ | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } }, | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } }, | ||
| * }); | ||
@@ -277,0 +277,0 @@ * await memory.initialize(); |
+2
-2
@@ -24,3 +24,3 @@ import { MemoryClient, MemoryClientConfig } from './browser.js'; | ||
| * const client = new AtomicMemoryClient({ | ||
| * apiUrl: 'http://localhost:3050', | ||
| * apiUrl: 'http://localhost:17350', | ||
| * apiKey: process.env.ATOMICMEMORY_API_KEY!, | ||
@@ -274,3 +274,3 @@ * userId: 'u1', | ||
| * const memory = new MemoryClient({ | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } }, | ||
| * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } }, | ||
| * }); | ||
@@ -277,0 +277,0 @@ * await memory.initialize(); |
+3
-3
@@ -1,4 +0,4 @@ | ||
| import { MemoryClient } from './chunk-4ZK445ML.js'; | ||
| export { MemoryClient } from './chunk-4ZK445ML.js'; | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, noopMemoryPipeline } from './chunk-75KDUWRG.js'; | ||
| import { MemoryClient } from './chunk-265G225P.js'; | ||
| export { MemoryClient } from './chunk-265G225P.js'; | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, noopMemoryPipeline } from './chunk-YBN5Y627.js'; | ||
| export { DEFAULT_VALIDATION_CONFIG, IndexedDBStorageAdapter, MemoryStorageAdapter, StorageManager, StorageValidator, assertValidKey, assertValidKeyValue, assertValidValue, validateKey, validateKeyValue, validateValue } from './chunk-4H2WXRAW.js'; | ||
@@ -5,0 +5,0 @@ import { ConcreteStorageClient } from './chunk-OFIOAOM3.js'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/client/atomic-memory-client.ts","../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4DO,IAAM,qBAAN,MAAyB;AAAA,EACrB,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,MAAA,EAAkC;AAC5C,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AAOA,IAAA,IAAA,CAAK,SAAS,IAAI,YAAA;AAAA,MAChB,OAAO,MAAA,IAAU;AAAA,QACf,SAAA,EAAW;AAAA,UACT,cAAc,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA;AAAO;AAC/D;AACF,KACF;AACA,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,qBAAA,CAAsB;AAAA,MACvC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,OAAO,MAAA,CAAO;AAAA,KACf,CAAA;AAAA,EACH;AACF;;;ACsDO,IAAM,WAAA,GAAc;AACpB,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * @file `AtomicMemoryClient` — primary public surface for the SDK.\n *\n * Aggregates `memory` (the memory-layer API) and `storage` (the\n * direct-storage API) under one client so callers see a coherent\n * single entry point:\n *\n * import { AtomicMemoryClient } from '@atomicmemory/sdk';\n * const client = new AtomicMemoryClient({\n * apiUrl: 'http://localhost:3050',\n * apiKey: process.env.ATOMICMEMORY_API_KEY!,\n * userId: 'u1',\n * });\n * await client.memory.initialize();\n * const artifact = await client.storage.put({\n * mode: 'pointer',\n * uri: 'https://example.com/file.pdf',\n * contentType: 'application/pdf',\n * });\n *\n * v1 SDK is server-side only. Browser bundles must proxy through a\n * trusted server, such as an application-owned API boundary.\n *\n * Applications that only need memory operations can still use\n * `MemoryClient` directly. New integrations should prefer\n * `AtomicMemoryClient.memory`.\n */\n\nimport { MemoryClient, type MemoryClientConfig } from './memory-client';\nimport { ConcreteStorageClient } from '../storage/client';\nimport type { StorageClient } from '../storage/interfaces';\n\n/**\n * Constructor config for the aggregator. All three transport fields\n * (`apiUrl`, `apiKey`, `userId`) are REQUIRED — they back both the\n * storage namespace and the default AtomicMemory memory provider.\n * Memory-only consumers should still pass `apiUrl` (it doubles as\n * the default memory provider's `apiUrl`); the `memory` block then\n * narrows the registration further if a non-default provider mix is\n * needed.\n *\n * `userId` is the owner-scope seam the storage routes accept until a\n * real auth seam ships. `fetch` is an optional override; defaults to\n * the Node global.\n */\nexport interface AtomicMemoryClientConfig {\n apiUrl: string;\n apiKey: string;\n userId: string;\n /** Optional fetch override — defaults to the Node global. */\n fetch?: typeof fetch;\n /** Memory-provider registration. Defaults to a single AtomicMemory\n * provider pointing at `apiUrl`. */\n memory?: MemoryClientConfig;\n}\n\n/**\n * Primary public client. Holds a `memory` namespace (`MemoryClient`)\n * and a `storage` namespace (`StorageClient`).\n */\nexport class AtomicMemoryClient {\n readonly memory: MemoryClient;\n readonly storage: StorageClient;\n\n constructor(config: AtomicMemoryClientConfig) {\n if (!config.apiUrl) {\n throw new Error('AtomicMemoryClient: apiUrl is required');\n }\n if (!config.apiKey) {\n throw new Error('AtomicMemoryClient: apiKey is required');\n }\n if (!config.userId) {\n throw new Error('AtomicMemoryClient: userId is required');\n }\n // Default provider registration MUST forward the apiKey so the\n // memory namespace shares the storage namespace's auth contract.\n // The earlier shape dropped it silently — memory requests went\n // out unauthenticated even when the caller supplied `apiKey`,\n // failing with 401 against any core deployment that gates `/v1/*`\n // (every deployment since the auth middleware landed).\n this.memory = new MemoryClient(\n config.memory ?? {\n providers: {\n atomicmemory: { apiUrl: config.apiUrl, apiKey: config.apiKey },\n },\n },\n );\n this.storage = new ConcreteStorageClient({\n apiUrl: config.apiUrl,\n apiKey: config.apiKey,\n userId: config.userId,\n fetch: config.fetch,\n });\n }\n}\n","/**\n * @file @atomicmemory/sdk public surface\n *\n * Backend-agnostic memory-layer SDK. Pluggable providers, local\n * embeddings, storage adapters, semantic search.\n *\n * @example\n * ```typescript\n * import { MemoryClient } from '@atomicmemory/sdk';\n *\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hello', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hello', scope: { user: 'u1' } });\n * ```\n */\n\n// Primary client — `AtomicMemoryClient` aggregates the memory and\n// storage namespaces. `MemoryClient` remains available for\n// applications that only need memory operations.\nexport {\n AtomicMemoryClient,\n type AtomicMemoryClientConfig,\n} from './client/atomic-memory-client';\n\nexport { MemoryClient } from './client/memory-client';\nexport type {\n MemoryClientConfig,\n MemoryProviderConfigs,\n ProviderStatus,\n} from './client/memory-client';\n\n// Types\nexport * from './types';\n\n// Event system\nexport { EventEmitter, type EventMap } from './core/events';\n\n// Error handling\nexport {\n AtomicMemoryError,\n StorageError,\n EmbeddingError,\n SearchError,\n ConfigurationError,\n NetworkError,\n RetryableOperation,\n withRetry,\n ErrorContext,\n ErrorUtils,\n type RetryPolicy,\n} from './core/error-handling/';\n\n// KV cache used by embeddings and local search. New artifact-storage\n// integrations should use the `./storage` subpath.\nexport { StorageManager } from './kv-cache/storage-manager';\nexport { MemoryStorageAdapter } from './kv-cache/memory-storage';\nexport { IndexedDBStorageAdapter } from './kv-cache/indexeddb-storage';\nexport type { StorageAdapter, StorageStats } from './kv-cache/storage-adapter';\n\n// KV cache validation\nexport {\n StorageValidator,\n validateKey,\n validateValue,\n validateKeyValue,\n assertValidKey,\n assertValidValue,\n assertValidKeyValue,\n DEFAULT_VALIDATION_CONFIG,\n} from './kv-cache/validation';\nexport type { ValidationConfig, ValidationResult } from './kv-cache/validation';\n\n// Storage API for the public `client.storage` namespace.\nexport * from './storage';\n\n// Logging\nexport {\n Logger,\n getLogger,\n configureLogging,\n setLogLevel,\n logger,\n} from './utils/logger';\nexport type {\n LogLevel,\n LogContext,\n LogEntry,\n LoggerConfig,\n} from './utils/logger';\n\n// Debug logging\nexport {\n setDebugHandler,\n setDebugEnabled,\n isDebugEnabled,\n debugLog,\n debugInfo,\n debugWarn,\n debugError,\n} from './utils/debug-logger';\nexport type { DebugLogEntry, DebugLogHandler } from './utils/debug-logger';\n\n// Embedding\nexport { EmbeddingGenerator } from './embedding/embedding-generator';\nexport { TransformersAdapter } from './embedding/transformers-adapter';\nexport { WasmSemanticProcessor } from './embedding/wasm-semantic-processor';\nexport { testWebAssemblySupport } from './embedding/wasm-semantic-processor';\n\n// Search\nexport { SemanticSearch } from './search/semantic-search';\nexport { cosineSimilarity } from './search/similarity-calculator';\nexport type {\n SemanticSearchResult,\n SearchOptions,\n StoredContext,\n} from './search/semantic-search/types';\n\n// Utilities\nexport { PerformanceMonitor } from './utils/performance';\nexport { DebugTools } from './utils/debugging';\nexport * from './utils/validation';\nexport {\n getEnvironment,\n isTestEnvironment,\n isDevelopmentEnvironment,\n isExtensionEnvironment,\n} from './utils/environment';\n\n// Runtime configuration — singleton consumed by application wrappers\n// that need to initialize environment settings at SDK startup.\nexport { RuntimeConfig, runtimeConfig } from './core/runtime-config';\n\n// Memory system — types, provider interface, concrete adapters.\n// `MemoryService` is intentionally not re-exported from root; consumers\n// use `MemoryClient` (above) as the canonical API.\nexport * from './memory/types';\nexport * from './memory/errors';\nexport * from './memory/provider';\nexport * from './memory/pipeline';\nexport * from './memory/registration';\nexport * from './memory/atomicmemory-provider';\nexport * from './memory/mem0-provider';\nexport * from './memory/hindsight-provider';\n\n// Version information\nexport const SDK_VERSION = '1.0.0';\nexport const API_VERSION = '1.0';\n"]} | ||
| {"version":3,"sources":["../src/client/atomic-memory-client.ts","../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA4DO,IAAM,qBAAN,MAAyB;AAAA,EACrB,MAAA;AAAA,EACA,OAAA;AAAA,EAET,YAAY,MAAA,EAAkC;AAC5C,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AACA,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,IAC1D;AAOA,IAAA,IAAA,CAAK,SAAS,IAAI,YAAA;AAAA,MAChB,OAAO,MAAA,IAAU;AAAA,QACf,SAAA,EAAW;AAAA,UACT,cAAc,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAQ,MAAA,EAAQ,OAAO,MAAA;AAAO;AAC/D;AACF,KACF;AACA,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,qBAAA,CAAsB;AAAA,MACvC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,OAAO,MAAA,CAAO;AAAA,KACf,CAAA;AAAA,EACH;AACF;;;ACsDO,IAAM,WAAA,GAAc;AACpB,IAAM,WAAA,GAAc","file":"index.js","sourcesContent":["/**\n * @file `AtomicMemoryClient` — primary public surface for the SDK.\n *\n * Aggregates `memory` (the memory-layer API) and `storage` (the\n * direct-storage API) under one client so callers see a coherent\n * single entry point:\n *\n * import { AtomicMemoryClient } from '@atomicmemory/sdk';\n * const client = new AtomicMemoryClient({\n * apiUrl: 'http://localhost:17350',\n * apiKey: process.env.ATOMICMEMORY_API_KEY!,\n * userId: 'u1',\n * });\n * await client.memory.initialize();\n * const artifact = await client.storage.put({\n * mode: 'pointer',\n * uri: 'https://example.com/file.pdf',\n * contentType: 'application/pdf',\n * });\n *\n * v1 SDK is server-side only. Browser bundles must proxy through a\n * trusted server, such as an application-owned API boundary.\n *\n * Applications that only need memory operations can still use\n * `MemoryClient` directly. New integrations should prefer\n * `AtomicMemoryClient.memory`.\n */\n\nimport { MemoryClient, type MemoryClientConfig } from './memory-client';\nimport { ConcreteStorageClient } from '../storage/client';\nimport type { StorageClient } from '../storage/interfaces';\n\n/**\n * Constructor config for the aggregator. All three transport fields\n * (`apiUrl`, `apiKey`, `userId`) are REQUIRED — they back both the\n * storage namespace and the default AtomicMemory memory provider.\n * Memory-only consumers should still pass `apiUrl` (it doubles as\n * the default memory provider's `apiUrl`); the `memory` block then\n * narrows the registration further if a non-default provider mix is\n * needed.\n *\n * `userId` is the owner-scope seam the storage routes accept until a\n * real auth seam ships. `fetch` is an optional override; defaults to\n * the Node global.\n */\nexport interface AtomicMemoryClientConfig {\n apiUrl: string;\n apiKey: string;\n userId: string;\n /** Optional fetch override — defaults to the Node global. */\n fetch?: typeof fetch;\n /** Memory-provider registration. Defaults to a single AtomicMemory\n * provider pointing at `apiUrl`. */\n memory?: MemoryClientConfig;\n}\n\n/**\n * Primary public client. Holds a `memory` namespace (`MemoryClient`)\n * and a `storage` namespace (`StorageClient`).\n */\nexport class AtomicMemoryClient {\n readonly memory: MemoryClient;\n readonly storage: StorageClient;\n\n constructor(config: AtomicMemoryClientConfig) {\n if (!config.apiUrl) {\n throw new Error('AtomicMemoryClient: apiUrl is required');\n }\n if (!config.apiKey) {\n throw new Error('AtomicMemoryClient: apiKey is required');\n }\n if (!config.userId) {\n throw new Error('AtomicMemoryClient: userId is required');\n }\n // Default provider registration MUST forward the apiKey so the\n // memory namespace shares the storage namespace's auth contract.\n // The earlier shape dropped it silently — memory requests went\n // out unauthenticated even when the caller supplied `apiKey`,\n // failing with 401 against any core deployment that gates `/v1/*`\n // (every deployment since the auth middleware landed).\n this.memory = new MemoryClient(\n config.memory ?? {\n providers: {\n atomicmemory: { apiUrl: config.apiUrl, apiKey: config.apiKey },\n },\n },\n );\n this.storage = new ConcreteStorageClient({\n apiUrl: config.apiUrl,\n apiKey: config.apiKey,\n userId: config.userId,\n fetch: config.fetch,\n });\n }\n}\n","/**\n * @file @atomicmemory/sdk public surface\n *\n * Backend-agnostic memory-layer SDK. Pluggable providers, local\n * embeddings, storage adapters, semantic search.\n *\n * @example\n * ```typescript\n * import { MemoryClient } from '@atomicmemory/sdk';\n *\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:17350' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hello', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hello', scope: { user: 'u1' } });\n * ```\n */\n\n// Primary client — `AtomicMemoryClient` aggregates the memory and\n// storage namespaces. `MemoryClient` remains available for\n// applications that only need memory operations.\nexport {\n AtomicMemoryClient,\n type AtomicMemoryClientConfig,\n} from './client/atomic-memory-client';\n\nexport { MemoryClient } from './client/memory-client';\nexport type {\n MemoryClientConfig,\n MemoryProviderConfigs,\n ProviderStatus,\n} from './client/memory-client';\n\n// Types\nexport * from './types';\n\n// Event system\nexport { EventEmitter, type EventMap } from './core/events';\n\n// Error handling\nexport {\n AtomicMemoryError,\n StorageError,\n EmbeddingError,\n SearchError,\n ConfigurationError,\n NetworkError,\n RetryableOperation,\n withRetry,\n ErrorContext,\n ErrorUtils,\n type RetryPolicy,\n} from './core/error-handling/';\n\n// KV cache used by embeddings and local search. New artifact-storage\n// integrations should use the `./storage` subpath.\nexport { StorageManager } from './kv-cache/storage-manager';\nexport { MemoryStorageAdapter } from './kv-cache/memory-storage';\nexport { IndexedDBStorageAdapter } from './kv-cache/indexeddb-storage';\nexport type { StorageAdapter, StorageStats } from './kv-cache/storage-adapter';\n\n// KV cache validation\nexport {\n StorageValidator,\n validateKey,\n validateValue,\n validateKeyValue,\n assertValidKey,\n assertValidValue,\n assertValidKeyValue,\n DEFAULT_VALIDATION_CONFIG,\n} from './kv-cache/validation';\nexport type { ValidationConfig, ValidationResult } from './kv-cache/validation';\n\n// Storage API for the public `client.storage` namespace.\nexport * from './storage';\n\n// Logging\nexport {\n Logger,\n getLogger,\n configureLogging,\n setLogLevel,\n logger,\n} from './utils/logger';\nexport type {\n LogLevel,\n LogContext,\n LogEntry,\n LoggerConfig,\n} from './utils/logger';\n\n// Debug logging\nexport {\n setDebugHandler,\n setDebugEnabled,\n isDebugEnabled,\n debugLog,\n debugInfo,\n debugWarn,\n debugError,\n} from './utils/debug-logger';\nexport type { DebugLogEntry, DebugLogHandler } from './utils/debug-logger';\n\n// Embedding\nexport { EmbeddingGenerator } from './embedding/embedding-generator';\nexport { TransformersAdapter } from './embedding/transformers-adapter';\nexport { WasmSemanticProcessor } from './embedding/wasm-semantic-processor';\nexport { testWebAssemblySupport } from './embedding/wasm-semantic-processor';\n\n// Search\nexport { SemanticSearch } from './search/semantic-search';\nexport { cosineSimilarity } from './search/similarity-calculator';\nexport type {\n SemanticSearchResult,\n SearchOptions,\n StoredContext,\n} from './search/semantic-search/types';\n\n// Utilities\nexport { PerformanceMonitor } from './utils/performance';\nexport { DebugTools } from './utils/debugging';\nexport * from './utils/validation';\nexport {\n getEnvironment,\n isTestEnvironment,\n isDevelopmentEnvironment,\n isExtensionEnvironment,\n} from './utils/environment';\n\n// Runtime configuration — singleton consumed by application wrappers\n// that need to initialize environment settings at SDK startup.\nexport { RuntimeConfig, runtimeConfig } from './core/runtime-config';\n\n// Memory system — types, provider interface, concrete adapters.\n// `MemoryService` is intentionally not re-exported from root; consumers\n// use `MemoryClient` (above) as the canonical API.\nexport * from './memory/types';\nexport * from './memory/errors';\nexport * from './memory/provider';\nexport * from './memory/pipeline';\nexport * from './memory/registration';\nexport * from './memory/atomicmemory-provider';\nexport * from './memory/mem0-provider';\nexport * from './memory/hindsight-provider';\n\n// Version information\nexport const SDK_VERSION = '1.0.0';\nexport const API_VERSION = '1.0';\n"]} |
+24
-24
| 'use strict'; | ||
| var chunkIK2P4INW_cjs = require('./chunk-IK2P4INW.cjs'); | ||
| var chunkGHOB6O5U_cjs = require('./chunk-GHOB6O5U.cjs'); | ||
@@ -9,93 +9,93 @@ | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "ATOMICMEMORY_EXTENSION_NAMES", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| get: function () { return chunkGHOB6O5U_cjs.ATOMICMEMORY_EXTENSION_NAMES; } | ||
| }); | ||
| Object.defineProperty(exports, "AtomicMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.AtomicMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.AtomicMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "BaseMemoryProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.BaseMemoryProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.BaseMemoryProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "DEFAULT_META_FACT_PATTERNS", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.DEFAULT_META_FACT_PATTERNS; } | ||
| get: function () { return chunkGHOB6O5U_cjs.DEFAULT_META_FACT_PATTERNS; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_API_VERSION", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_API_VERSION; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_MAX_TOKENS", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_MAX_TOKENS; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_PROJECT_ID", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_PROJECT_ID; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "HINDSIGHT_SCOPE_TAGS_MATCH", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HINDSIGHT_SCOPE_TAGS_MATCH; } | ||
| }); | ||
| Object.defineProperty(exports, "HindsightProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.HindsightProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.HindsightProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "InvalidScopeError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.InvalidScopeError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.InvalidScopeError; } | ||
| }); | ||
| Object.defineProperty(exports, "MEM0_DEFAULT_TIMEOUT", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MEM0_DEFAULT_TIMEOUT; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0ContextProvider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0ContextProvider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0ContextProvider; } | ||
| }); | ||
| Object.defineProperty(exports, "Mem0Provider", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.Mem0Provider; } | ||
| get: function () { return chunkGHOB6O5U_cjs.Mem0Provider; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryProviderError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryProviderError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryProviderError; } | ||
| }); | ||
| Object.defineProperty(exports, "MemoryTransportError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.MemoryTransportError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.MemoryTransportError; } | ||
| }); | ||
| Object.defineProperty(exports, "RateLimitError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.RateLimitError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.RateLimitError; } | ||
| }); | ||
| Object.defineProperty(exports, "UnsupportedOperationError", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.UnsupportedOperationError; } | ||
| get: function () { return chunkGHOB6O5U_cjs.UnsupportedOperationError; } | ||
| }); | ||
| Object.defineProperty(exports, "filterMetaFacts", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.filterMetaFacts; } | ||
| get: function () { return chunkGHOB6O5U_cjs.filterMetaFacts; } | ||
| }); | ||
| Object.defineProperty(exports, "isMetaFact", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.isMetaFact; } | ||
| get: function () { return chunkGHOB6O5U_cjs.isMetaFact; } | ||
| }); | ||
| Object.defineProperty(exports, "noopMemoryPipeline", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.noopMemoryPipeline; } | ||
| get: function () { return chunkGHOB6O5U_cjs.noopMemoryPipeline; } | ||
| }); | ||
| Object.defineProperty(exports, "resolveMetaFactPatterns", { | ||
| enumerable: true, | ||
| get: function () { return chunkIK2P4INW_cjs.resolveMetaFactPatterns; } | ||
| get: function () { return chunkGHOB6O5U_cjs.resolveMetaFactPatterns; } | ||
| }); | ||
| //# sourceMappingURL=memory.cjs.map | ||
| //# sourceMappingURL=memory.cjs.map |
@@ -437,3 +437,3 @@ /** | ||
| interface AtomicMemoryProviderConfig { | ||
| /** Base URL of the atomicmemory-core instance, e.g. `http://localhost:3050`. */ | ||
| /** Base URL of the atomicmemory-core instance, e.g. `http://localhost:17350`. */ | ||
| apiUrl: string; | ||
@@ -440,0 +440,0 @@ /** Optional bearer token forwarded as `Authorization: Bearer <apiKey>`. */ |
+1
-1
@@ -437,3 +437,3 @@ /** | ||
| interface AtomicMemoryProviderConfig { | ||
| /** Base URL of the atomicmemory-core instance, e.g. `http://localhost:3050`. */ | ||
| /** Base URL of the atomicmemory-core instance, e.g. `http://localhost:17350`. */ | ||
| apiUrl: string; | ||
@@ -440,0 +440,0 @@ /** Optional bearer token forwarded as `Authorization: Bearer <apiKey>`. */ |
+1
-1
@@ -1,3 +0,3 @@ | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, DEFAULT_META_FACT_PATTERNS, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, filterMetaFacts, isMetaFact, noopMemoryPipeline, resolveMetaFactPatterns } from './chunk-75KDUWRG.js'; | ||
| export { ATOMICMEMORY_DEFAULT_TIMEOUT, ATOMICMEMORY_EXTENSION_NAMES, AtomicMemoryProvider, BaseMemoryProvider, DEFAULT_META_FACT_PATTERNS, HINDSIGHT_DEFAULT_API_VERSION, HINDSIGHT_DEFAULT_MAX_TOKENS, HINDSIGHT_DEFAULT_PROJECT_ID, HINDSIGHT_DEFAULT_TIMEOUT, HINDSIGHT_SCOPE_TAGS_MATCH, HindsightProvider, InvalidScopeError, MEM0_DEFAULT_TIMEOUT, Mem0ContextProvider, Mem0Provider, MemoryProviderError, MemoryTransportError, RateLimitError, UnsupportedOperationError, filterMetaFacts, isMetaFact, noopMemoryPipeline, resolveMetaFactPatterns } from './chunk-YBN5Y627.js'; | ||
| //# sourceMappingURL=memory.js.map | ||
| //# sourceMappingURL=memory.js.map |
+1
-1
| { | ||
| "name": "@atomicmemory/sdk", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "engines": { |
+3
-3
@@ -50,3 +50,3 @@ # @atomicmemory/sdk | ||
| const client = new AtomicMemoryClient({ | ||
| apiUrl: 'http://localhost:3050', | ||
| apiUrl: 'http://localhost:17350', | ||
| apiKey: process.env.ATOMICMEMORY_API_KEY!, | ||
@@ -56,3 +56,3 @@ userId: 'demo-user', | ||
| providers: { | ||
| atomicmemory: { apiUrl: 'http://localhost:3050' }, | ||
| atomicmemory: { apiUrl: 'http://localhost:17350' }, | ||
| }, | ||
@@ -95,3 +95,3 @@ }, | ||
| atomicmemory: { | ||
| apiUrl: 'http://localhost:3050', | ||
| apiUrl: 'http://localhost:17350', | ||
| apiKey: process.env.ATOMICMEMORY_API_KEY, | ||
@@ -98,0 +98,0 @@ timeout: 30_000, |
| import { HindsightProvider, Mem0Provider, AtomicMemoryProvider, noopMemoryPipeline, UnsupportedOperationError } from './chunk-75KDUWRG.js'; | ||
| // src/memory/providers/registry.ts | ||
| var defaultRegistry = { | ||
| atomicmemory: (config) => ({ | ||
| provider: new AtomicMemoryProvider(config) | ||
| }), | ||
| mem0: (config) => ({ | ||
| provider: new Mem0Provider(config) | ||
| }), | ||
| hindsight: (config) => ({ | ||
| provider: new HindsightProvider(config) | ||
| }) | ||
| }; | ||
| // src/memory/memory-service.ts | ||
| var MemoryService = class { | ||
| constructor(config) { | ||
| this.config = config; | ||
| this.defaultProviderName = config.defaultProvider; | ||
| } | ||
| config; | ||
| providers = /* @__PURE__ */ new Map(); | ||
| pipelines = /* @__PURE__ */ new Map(); | ||
| defaultProviderName; | ||
| async initialize(registry = defaultRegistry) { | ||
| for (const [name, providerConfig] of Object.entries( | ||
| this.config.providerConfigs | ||
| )) { | ||
| const factory = registry[name]; | ||
| if (!factory) continue; | ||
| const registration = factory(providerConfig); | ||
| this.providers.set(name, registration.provider); | ||
| this.pipelines.set( | ||
| name, | ||
| registration.pipeline ?? noopMemoryPipeline | ||
| ); | ||
| if (registration.provider.initialize) { | ||
| await registration.provider.initialize(); | ||
| } | ||
| } | ||
| } | ||
| getProvider(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| const provider = this.providers.get(providerName); | ||
| if (!provider) { | ||
| throw new Error( | ||
| `Provider "${providerName}" is not registered` | ||
| ); | ||
| } | ||
| return provider; | ||
| } | ||
| getAvailableProviders() { | ||
| return Array.from(this.providers.keys()); | ||
| } | ||
| /** | ||
| * Provider names declared in the SDK configuration, regardless of whether | ||
| * they have been initialized yet. Useful for UI and getter paths that | ||
| * need to advertise capabilities before `initialize()` has run. | ||
| */ | ||
| getConfiguredProviders() { | ||
| return Object.keys(this.config.providerConfigs); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Core operations | ||
| // ----------------------------------------------------------------------- | ||
| async ingest(input, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| if (pipeline.preprocessIngest) { | ||
| const inputs = await pipeline.preprocessIngest(input); | ||
| const results = []; | ||
| for (const i of inputs) { | ||
| const result2 = await provider.ingest(i); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result2, i); | ||
| } | ||
| results.push(result2); | ||
| } | ||
| return mergeIngestResults(results); | ||
| } | ||
| const result = await provider.ingest(input); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result, input); | ||
| } | ||
| return result; | ||
| } | ||
| async search(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRequest = pipeline.preprocessSearch ? await pipeline.preprocessSearch(request) : request; | ||
| const page = await provider.search(processedRequest); | ||
| return pipeline.postprocessSearch ? await pipeline.postprocessSearch(page, processedRequest) : page; | ||
| } | ||
| async get(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRef = pipeline.preprocessGet ? await pipeline.preprocessGet(ref) : ref; | ||
| const memory = await provider.get(processedRef); | ||
| return pipeline.postprocessGet ? await pipeline.postprocessGet(memory, processedRef) : memory; | ||
| } | ||
| async delete(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| await provider.delete(ref); | ||
| } | ||
| async list(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const page = await provider.list(request); | ||
| return pipeline.postprocessList ? await pipeline.postprocessList(page, request) : page; | ||
| } | ||
| async package(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const packager = provider.getExtension?.("package"); | ||
| if (!packager) { | ||
| throw new UnsupportedOperationError( | ||
| provider.name, | ||
| "package" | ||
| ); | ||
| } | ||
| return packager.package(request); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Internals | ||
| // ----------------------------------------------------------------------- | ||
| getPipeline(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| return this.pipelines.get(providerName) ?? noopMemoryPipeline; | ||
| } | ||
| }; | ||
| function mergeIngestResults(results) { | ||
| return { | ||
| created: results.flatMap((r) => r.created), | ||
| updated: results.flatMap((r) => r.updated), | ||
| unchanged: results.flatMap((r) => r.unchanged) | ||
| }; | ||
| } | ||
| // src/client/memory-client.ts | ||
| var MemoryClient = class { | ||
| service; | ||
| initialized = false; | ||
| constructor(config) { | ||
| const providerConfigs = { ...config.providers }; | ||
| const defaultProvider = config.defaultProvider ?? pickFirstProviderKey(providerConfigs); | ||
| if (!defaultProvider) { | ||
| throw new Error( | ||
| 'MemoryClient requires at least one provider config. Pass e.g. { providers: { atomicmemory: { apiUrl: "..." } } }.' | ||
| ); | ||
| } | ||
| this.service = new MemoryService({ | ||
| defaultProvider, | ||
| providerConfigs | ||
| }); | ||
| } | ||
| /** | ||
| * Initialize all configured providers. Must be called before any | ||
| * memory operation. Idempotent. | ||
| */ | ||
| async initialize(registry = defaultRegistry) { | ||
| if (this.initialized) return; | ||
| await this.service.initialize(registry); | ||
| this.initialized = true; | ||
| } | ||
| /** | ||
| * Write memory(ies). Input supports `text`, `messages`, or `memory` modes. | ||
| */ | ||
| async ingest(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Ingest without any application-layer gating. Equivalent to `ingest()` | ||
| * on the core client; application wrappers override the gated variant | ||
| * while delegating this path straight through. | ||
| */ | ||
| async ingestDirect(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Search for memories matching the request. | ||
| */ | ||
| async search(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Search without application-layer gating. See `ingestDirect` for the | ||
| * rationale. | ||
| */ | ||
| async searchDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Build an injection-ready context package from a scoped request. | ||
| * Provider must implement the `package` extension. | ||
| */ | ||
| async package(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Package without application-layer gating. | ||
| */ | ||
| async packageDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Fetch a single memory by reference. | ||
| */ | ||
| async get(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.get(ref); | ||
| } | ||
| /** | ||
| * Delete a single memory by reference. | ||
| */ | ||
| async delete(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.delete(ref); | ||
| } | ||
| /** | ||
| * List memories within a scope. | ||
| */ | ||
| async list(request) { | ||
| this.assertInitialized(); | ||
| return this.service.list(request); | ||
| } | ||
| /** | ||
| * Report the capability surface of the default (or named) provider. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| */ | ||
| capabilities(providerName) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(providerName).capabilities(); | ||
| } | ||
| /** | ||
| * Resolve a named extension on the default (or named) provider. | ||
| * Returns `undefined` when the provider does not advertise the | ||
| * extension. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const pkg = memory.getExtension<Packager>('package'); | ||
| * ``` | ||
| */ | ||
| getExtension(extensionName, providerName) { | ||
| this.assertInitialized(); | ||
| const provider = this.service.getProvider(providerName); | ||
| return provider.getExtension?.(extensionName); | ||
| } | ||
| /** | ||
| * Aggregate status of all configured providers. Never throws: | ||
| * uninitialized providers report `initialized: false` and | ||
| * `capabilities: null`. | ||
| */ | ||
| getProviderStatus() { | ||
| const configured = this.service.getConfiguredProviders(); | ||
| const available = new Set(this.service.getAvailableProviders()); | ||
| return configured.map((name) => { | ||
| if (!available.has(name)) { | ||
| return { name, initialized: false, capabilities: null }; | ||
| } | ||
| return { | ||
| name, | ||
| initialized: true, | ||
| capabilities: this.service.getProvider(name).capabilities() | ||
| }; | ||
| }); | ||
| } | ||
| /** | ||
| * Access the full AtomicMemory namespace handle (lifecycle, audit, | ||
| * lessons, config, agents). Returns `undefined` when the client is | ||
| * not yet initialized, the `atomicmemory` provider was not included | ||
| * in the `providers` config, or that provider does not advertise the | ||
| * namespace handle. This getter intentionally never throws — callers | ||
| * can guard with a truthy check and let the handle's own methods | ||
| * raise if used incorrectly. | ||
| */ | ||
| get atomicmemory() { | ||
| if (!this.initialized) return void 0; | ||
| if (!this.service.getConfiguredProviders().includes("atomicmemory")) { | ||
| return void 0; | ||
| } | ||
| const provider = this.service.getProvider("atomicmemory"); | ||
| return provider.getExtension?.("atomicmemory.base"); | ||
| } | ||
| /** | ||
| * Low-level escape hatch for callers that need the concrete provider. | ||
| */ | ||
| getProvider(name) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(name); | ||
| } | ||
| assertInitialized() { | ||
| if (!this.initialized) { | ||
| throw new Error( | ||
| "MemoryClient is not initialized. Call `await client.initialize()` first." | ||
| ); | ||
| } | ||
| } | ||
| }; | ||
| function pickFirstProviderKey(providers) { | ||
| for (const [key, value] of Object.entries(providers)) { | ||
| if (value !== void 0 && key !== "default") return key; | ||
| } | ||
| return void 0; | ||
| } | ||
| export { MemoryClient }; | ||
| //# sourceMappingURL=chunk-4ZK445ML.js.map | ||
| //# sourceMappingURL=chunk-4ZK445ML.js.map |
| {"version":3,"sources":["../src/memory/providers/registry.ts","../src/memory/memory-service.ts","../src/client/memory-client.ts"],"names":["result"],"mappings":";;;AAoBO,IAAM,eAAA,GAAoC;AAAA,EAC/C,YAAA,EAAc,CAAC,MAAA,MAAoE;AAAA,IACjF,QAAA,EAAU,IAAI,oBAAA,CAAqB,MAAM;AAAA,GAC3C,CAAA;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,CAAC,IAAA,CAAK,OAAA,CAAQ,wBAAuB,CAAE,QAAA,CAAS,cAAc,CAAA,EAAG;AACnE,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,cAAc,CAAA;AACxD,IAAA,OAAO,QAAA,CAAS,eAAmC,mBAAmB,CAAA;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY,IAAA,EAA+B;AACzC,IAAA,IAAA,CAAK,iBAAA,EAAkB;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,IAAI,CAAA;AAAA,EACtC;AAAA,EAEQ,iBAAA,GAA0B;AAChC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,SAAA,EAAwD;AACpF,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpD,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,GAAA,KAAQ,SAAA,EAAW,OAAO,GAAA;AAAA,EACvD;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-4ZK445ML.js","sourcesContent":["/**\n * @file Memory Provider Registry\n *\n * Maps provider names to factory functions that create\n * MemoryProviderRegistration instances from configuration.\n */\n\nimport type { MemoryProviderRegistration } from '../registration';\nimport type { AtomicMemoryProviderConfig } from '../atomicmemory-provider/types';\nimport { AtomicMemoryProvider } from '../atomicmemory-provider/atomicmemory-provider';\nimport type { Mem0ProviderConfig } from '../mem0-provider/types';\nimport { Mem0Provider } from '../mem0-provider/mem0-provider';\nimport type { HindsightProviderConfig } from '../hindsight-provider/types';\nimport { HindsightProvider } from '../hindsight-provider/hindsight-provider';\n\nexport type ProviderRegistry = Record<\n string,\n (config: any) => MemoryProviderRegistration\n>;\n\nexport const defaultRegistry: ProviderRegistry = {\n atomicmemory: (config: AtomicMemoryProviderConfig): MemoryProviderRegistration => ({\n provider: new AtomicMemoryProvider(config),\n }),\n mem0: (config: Mem0ProviderConfig): MemoryProviderRegistration => ({\n provider: new Mem0Provider(config),\n }),\n hindsight: (config: HindsightProviderConfig): MemoryProviderRegistration => ({\n provider: new HindsightProvider(config),\n }),\n};\n","/**\n * @file Memory Service\n *\n * Replaces UnifiedContextService. Routes operations to the correct\n * provider and applies optional processing pipelines.\n */\n\nimport type { MemoryProvider, Packager } from './provider';\nimport type { MemoryProcessingPipeline } from './pipeline';\nimport { noopMemoryPipeline } from './pipeline';\nimport type { MemoryProviderRegistration } from './registration';\nimport { UnsupportedOperationError } from './errors';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n} from './types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from './providers/registry';\n\nexport interface MemoryServiceConfig {\n defaultProvider: string;\n providerConfigs: Record<string, unknown>;\n}\n\nexport class MemoryService {\n private providers = new Map<string, MemoryProvider>();\n private pipelines = new Map<string, MemoryProcessingPipeline>();\n private defaultProviderName: string;\n\n constructor(private readonly config: MemoryServiceConfig) {\n this.defaultProviderName = config.defaultProvider;\n }\n\n async initialize(\n registry: ProviderRegistry = defaultRegistry\n ): Promise<void> {\n for (const [name, providerConfig] of Object.entries(\n this.config.providerConfigs\n )) {\n const factory = registry[name];\n if (!factory) continue;\n const registration: MemoryProviderRegistration = factory(providerConfig);\n this.providers.set(name, registration.provider);\n this.pipelines.set(\n name,\n registration.pipeline ?? noopMemoryPipeline\n );\n\n if (registration.provider.initialize) {\n await registration.provider.initialize();\n }\n }\n }\n\n getProvider(name?: string): MemoryProvider {\n const providerName = name ?? this.defaultProviderName;\n const provider = this.providers.get(providerName);\n if (!provider) {\n throw new Error(\n `Provider \"${providerName}\" is not registered`\n );\n }\n return provider;\n }\n\n getAvailableProviders(): string[] {\n return Array.from(this.providers.keys());\n }\n\n /**\n * Provider names declared in the SDK configuration, regardless of whether\n * they have been initialized yet. Useful for UI and getter paths that\n * need to advertise capabilities before `initialize()` has run.\n */\n getConfiguredProviders(): string[] {\n return Object.keys(this.config.providerConfigs);\n }\n\n // -----------------------------------------------------------------------\n // Core operations\n // -----------------------------------------------------------------------\n\n async ingest(\n input: IngestInput,\n providerName?: string\n ): Promise<IngestResult> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n if (pipeline.preprocessIngest) {\n const inputs = await pipeline.preprocessIngest(input);\n const results: IngestResult[] = [];\n for (const i of inputs) {\n const result = await provider.ingest(i);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, i);\n }\n results.push(result);\n }\n return mergeIngestResults(results);\n }\n\n const result = await provider.ingest(input);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, input);\n }\n return result;\n }\n\n async search(\n request: SearchRequest,\n providerName?: string\n ): Promise<SearchResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRequest = pipeline.preprocessSearch\n ? await pipeline.preprocessSearch(request)\n : request;\n\n const page = await provider.search(processedRequest);\n\n return pipeline.postprocessSearch\n ? await pipeline.postprocessSearch(page, processedRequest)\n : page;\n }\n\n async get(\n ref: MemoryRef,\n providerName?: string\n ): Promise<Memory | null> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRef = pipeline.preprocessGet\n ? await pipeline.preprocessGet(ref)\n : ref;\n\n const memory = await provider.get(processedRef);\n\n return pipeline.postprocessGet\n ? await pipeline.postprocessGet(memory, processedRef)\n : memory;\n }\n\n async delete(\n ref: MemoryRef,\n providerName?: string\n ): Promise<void> {\n const provider = this.getProvider(providerName);\n await provider.delete(ref);\n }\n\n async list(\n request: ListRequest,\n providerName?: string\n ): Promise<ListResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const page = await provider.list(request);\n\n return pipeline.postprocessList\n ? await pipeline.postprocessList(page, request)\n : page;\n }\n\n async package(\n request: PackageRequest,\n providerName?: string\n ): Promise<ContextPackage> {\n const provider = this.getProvider(providerName);\n const packager = provider.getExtension?.<Packager>('package');\n if (!packager) {\n throw new UnsupportedOperationError(\n provider.name,\n 'package'\n );\n }\n return packager.package(request);\n }\n\n // -----------------------------------------------------------------------\n // Internals\n // -----------------------------------------------------------------------\n\n private getPipeline(\n name?: string\n ): MemoryProcessingPipeline {\n const providerName = name ?? this.defaultProviderName;\n return (\n this.pipelines.get(providerName) ?? noopMemoryPipeline\n );\n }\n}\n\nfunction mergeIngestResults(\n results: IngestResult[]\n): IngestResult {\n return {\n created: results.flatMap((r) => r.created),\n updated: results.flatMap((r) => r.updated),\n unchanged: results.flatMap((r) => r.unchanged),\n };\n}\n","/**\n * @file MemoryClient — primary public API for the memory-layer SDK\n *\n * Pure memory operations: ingest, search, package, list, get, delete,\n * capability inspection, and provider namespace handles. No policy\n * gating, no platform/targetDomain parameters — applications that need\n * those layer them on top of this client.\n */\n\nimport { MemoryService } from '../memory/memory-service';\nimport type { MemoryProvider } from '../memory/provider';\nimport type { AtomicMemoryProviderConfig } from '../memory/atomicmemory-provider/types';\nimport type { AtomicMemoryHandle } from '../memory/atomicmemory-provider/handle';\nimport type { Mem0ProviderConfig } from '../memory/mem0-provider/types';\nimport type { HindsightProviderConfig } from '../memory/hindsight-provider/types';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n Capabilities,\n} from '../memory/types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from '../memory/providers/registry';\n\n/**\n * Provider configuration map. Each key names a provider; the value is\n * that provider's configuration object.\n */\nexport interface MemoryProviderConfigs {\n atomicmemory?: AtomicMemoryProviderConfig;\n mem0?: Mem0ProviderConfig;\n hindsight?: HindsightProviderConfig;\n [providerName: string]: unknown;\n}\n\n/**\n * MemoryClient configuration.\n */\nexport interface MemoryClientConfig {\n /** Provider configurations keyed by provider name. */\n providers: MemoryProviderConfigs;\n /** Name of the default provider. If omitted, the first configured provider wins. */\n defaultProvider?: string;\n}\n\n/**\n * Status summary for each configured provider.\n */\nexport interface ProviderStatus {\n name: string;\n initialized: boolean;\n capabilities: Capabilities | null;\n}\n\n/**\n * MemoryClient — pure memory-layer API.\n *\n * @example\n * ```ts\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hi', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hi', scope: { user: 'u1' } });\n * ```\n */\nexport class MemoryClient {\n private readonly service: MemoryService;\n private initialized = false;\n\n constructor(config: MemoryClientConfig) {\n const providerConfigs: Record<string, unknown> = { ...config.providers };\n const defaultProvider =\n config.defaultProvider ?? pickFirstProviderKey(providerConfigs);\n\n if (!defaultProvider) {\n throw new Error(\n 'MemoryClient requires at least one provider config. ' +\n 'Pass e.g. { providers: { atomicmemory: { apiUrl: \"...\" } } }.'\n );\n }\n\n this.service = new MemoryService({\n defaultProvider,\n providerConfigs,\n });\n }\n\n /**\n * Initialize all configured providers. Must be called before any\n * memory operation. Idempotent.\n */\n async initialize(registry: ProviderRegistry = defaultRegistry): Promise<void> {\n if (this.initialized) return;\n await this.service.initialize(registry);\n this.initialized = true;\n }\n\n /**\n * Write memory(ies). Input supports `text`, `messages`, or `memory` modes.\n */\n async ingest(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Ingest without any application-layer gating. Equivalent to `ingest()`\n * on the core client; application wrappers override the gated variant\n * while delegating this path straight through.\n */\n async ingestDirect(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Search for memories matching the request.\n */\n async search(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Search without application-layer gating. See `ingestDirect` for the\n * rationale.\n */\n async searchDirect(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Build an injection-ready context package from a scoped request.\n * Provider must implement the `package` extension.\n */\n async package(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Package without application-layer gating.\n */\n async packageDirect(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Fetch a single memory by reference.\n */\n async get(ref: MemoryRef): Promise<Memory | null> {\n this.assertInitialized();\n return this.service.get(ref);\n }\n\n /**\n * Delete a single memory by reference.\n */\n async delete(ref: MemoryRef): Promise<void> {\n this.assertInitialized();\n return this.service.delete(ref);\n }\n\n /**\n * List memories within a scope.\n */\n async list(request: ListRequest): Promise<ListResultPage> {\n this.assertInitialized();\n return this.service.list(request);\n }\n\n /**\n * Report the capability surface of the default (or named) provider.\n *\n * @throws if the named provider is unknown or not initialized.\n */\n capabilities(providerName?: string): Capabilities {\n this.assertInitialized();\n return this.service.getProvider(providerName).capabilities();\n }\n\n /**\n * Resolve a named extension on the default (or named) provider.\n * Returns `undefined` when the provider does not advertise the\n * extension.\n *\n * @throws if the named provider is unknown or not initialized.\n *\n * @example\n * ```ts\n * const pkg = memory.getExtension<Packager>('package');\n * ```\n */\n getExtension<T>(extensionName: string, providerName?: string): T | undefined {\n this.assertInitialized();\n const provider = this.service.getProvider(providerName);\n return provider.getExtension?.<T>(extensionName);\n }\n\n /**\n * Aggregate status of all configured providers. Never throws:\n * uninitialized providers report `initialized: false` and\n * `capabilities: null`.\n */\n getProviderStatus(): ProviderStatus[] {\n const configured = this.service.getConfiguredProviders();\n const available = new Set(this.service.getAvailableProviders());\n return configured.map((name) => {\n if (!available.has(name)) {\n return { name, initialized: false, capabilities: null };\n }\n return {\n name,\n initialized: true,\n capabilities: this.service.getProvider(name).capabilities(),\n };\n });\n }\n\n /**\n * Access the full AtomicMemory namespace handle (lifecycle, audit,\n * lessons, config, agents). Returns `undefined` when the client is\n * not yet initialized, the `atomicmemory` provider was not included\n * in the `providers` config, or that provider does not advertise the\n * namespace handle. This getter intentionally never throws — callers\n * can guard with a truthy check and let the handle's own methods\n * raise if used incorrectly.\n */\n get atomicmemory(): AtomicMemoryHandle | undefined {\n if (!this.initialized) return undefined;\n if (!this.service.getConfiguredProviders().includes('atomicmemory')) {\n return undefined;\n }\n const provider = this.service.getProvider('atomicmemory');\n return provider.getExtension?.<AtomicMemoryHandle>('atomicmemory.base');\n }\n\n /**\n * Low-level escape hatch for callers that need the concrete provider.\n */\n getProvider(name?: string): MemoryProvider {\n this.assertInitialized();\n return this.service.getProvider(name);\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'MemoryClient is not initialized. Call `await client.initialize()` first.'\n );\n }\n }\n}\n\nfunction pickFirstProviderKey(providers: Record<string, unknown>): string | undefined {\n for (const [key, value] of Object.entries(providers)) {\n if (value !== undefined && key !== 'default') return key;\n }\n return undefined;\n}\n"]} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| 'use strict'; | ||
| var chunkIK2P4INW_cjs = require('./chunk-IK2P4INW.cjs'); | ||
| // src/memory/providers/registry.ts | ||
| var defaultRegistry = { | ||
| atomicmemory: (config) => ({ | ||
| provider: new chunkIK2P4INW_cjs.AtomicMemoryProvider(config) | ||
| }), | ||
| mem0: (config) => ({ | ||
| provider: new chunkIK2P4INW_cjs.Mem0Provider(config) | ||
| }), | ||
| hindsight: (config) => ({ | ||
| provider: new chunkIK2P4INW_cjs.HindsightProvider(config) | ||
| }) | ||
| }; | ||
| // src/memory/memory-service.ts | ||
| var MemoryService = class { | ||
| constructor(config) { | ||
| this.config = config; | ||
| this.defaultProviderName = config.defaultProvider; | ||
| } | ||
| config; | ||
| providers = /* @__PURE__ */ new Map(); | ||
| pipelines = /* @__PURE__ */ new Map(); | ||
| defaultProviderName; | ||
| async initialize(registry = defaultRegistry) { | ||
| for (const [name, providerConfig] of Object.entries( | ||
| this.config.providerConfigs | ||
| )) { | ||
| const factory = registry[name]; | ||
| if (!factory) continue; | ||
| const registration = factory(providerConfig); | ||
| this.providers.set(name, registration.provider); | ||
| this.pipelines.set( | ||
| name, | ||
| registration.pipeline ?? chunkIK2P4INW_cjs.noopMemoryPipeline | ||
| ); | ||
| if (registration.provider.initialize) { | ||
| await registration.provider.initialize(); | ||
| } | ||
| } | ||
| } | ||
| getProvider(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| const provider = this.providers.get(providerName); | ||
| if (!provider) { | ||
| throw new Error( | ||
| `Provider "${providerName}" is not registered` | ||
| ); | ||
| } | ||
| return provider; | ||
| } | ||
| getAvailableProviders() { | ||
| return Array.from(this.providers.keys()); | ||
| } | ||
| /** | ||
| * Provider names declared in the SDK configuration, regardless of whether | ||
| * they have been initialized yet. Useful for UI and getter paths that | ||
| * need to advertise capabilities before `initialize()` has run. | ||
| */ | ||
| getConfiguredProviders() { | ||
| return Object.keys(this.config.providerConfigs); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Core operations | ||
| // ----------------------------------------------------------------------- | ||
| async ingest(input, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| if (pipeline.preprocessIngest) { | ||
| const inputs = await pipeline.preprocessIngest(input); | ||
| const results = []; | ||
| for (const i of inputs) { | ||
| const result2 = await provider.ingest(i); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result2, i); | ||
| } | ||
| results.push(result2); | ||
| } | ||
| return mergeIngestResults(results); | ||
| } | ||
| const result = await provider.ingest(input); | ||
| if (pipeline.postprocessIngest) { | ||
| await pipeline.postprocessIngest(result, input); | ||
| } | ||
| return result; | ||
| } | ||
| async search(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRequest = pipeline.preprocessSearch ? await pipeline.preprocessSearch(request) : request; | ||
| const page = await provider.search(processedRequest); | ||
| return pipeline.postprocessSearch ? await pipeline.postprocessSearch(page, processedRequest) : page; | ||
| } | ||
| async get(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const processedRef = pipeline.preprocessGet ? await pipeline.preprocessGet(ref) : ref; | ||
| const memory = await provider.get(processedRef); | ||
| return pipeline.postprocessGet ? await pipeline.postprocessGet(memory, processedRef) : memory; | ||
| } | ||
| async delete(ref, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| await provider.delete(ref); | ||
| } | ||
| async list(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const pipeline = this.getPipeline(providerName); | ||
| const page = await provider.list(request); | ||
| return pipeline.postprocessList ? await pipeline.postprocessList(page, request) : page; | ||
| } | ||
| async package(request, providerName) { | ||
| const provider = this.getProvider(providerName); | ||
| const packager = provider.getExtension?.("package"); | ||
| if (!packager) { | ||
| throw new chunkIK2P4INW_cjs.UnsupportedOperationError( | ||
| provider.name, | ||
| "package" | ||
| ); | ||
| } | ||
| return packager.package(request); | ||
| } | ||
| // ----------------------------------------------------------------------- | ||
| // Internals | ||
| // ----------------------------------------------------------------------- | ||
| getPipeline(name) { | ||
| const providerName = name ?? this.defaultProviderName; | ||
| return this.pipelines.get(providerName) ?? chunkIK2P4INW_cjs.noopMemoryPipeline; | ||
| } | ||
| }; | ||
| function mergeIngestResults(results) { | ||
| return { | ||
| created: results.flatMap((r) => r.created), | ||
| updated: results.flatMap((r) => r.updated), | ||
| unchanged: results.flatMap((r) => r.unchanged) | ||
| }; | ||
| } | ||
| // src/client/memory-client.ts | ||
| var MemoryClient = class { | ||
| service; | ||
| initialized = false; | ||
| constructor(config) { | ||
| const providerConfigs = { ...config.providers }; | ||
| const defaultProvider = config.defaultProvider ?? pickFirstProviderKey(providerConfigs); | ||
| if (!defaultProvider) { | ||
| throw new Error( | ||
| 'MemoryClient requires at least one provider config. Pass e.g. { providers: { atomicmemory: { apiUrl: "..." } } }.' | ||
| ); | ||
| } | ||
| this.service = new MemoryService({ | ||
| defaultProvider, | ||
| providerConfigs | ||
| }); | ||
| } | ||
| /** | ||
| * Initialize all configured providers. Must be called before any | ||
| * memory operation. Idempotent. | ||
| */ | ||
| async initialize(registry = defaultRegistry) { | ||
| if (this.initialized) return; | ||
| await this.service.initialize(registry); | ||
| this.initialized = true; | ||
| } | ||
| /** | ||
| * Write memory(ies). Input supports `text`, `messages`, or `memory` modes. | ||
| */ | ||
| async ingest(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Ingest without any application-layer gating. Equivalent to `ingest()` | ||
| * on the core client; application wrappers override the gated variant | ||
| * while delegating this path straight through. | ||
| */ | ||
| async ingestDirect(input) { | ||
| this.assertInitialized(); | ||
| return this.service.ingest(input); | ||
| } | ||
| /** | ||
| * Search for memories matching the request. | ||
| */ | ||
| async search(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Search without application-layer gating. See `ingestDirect` for the | ||
| * rationale. | ||
| */ | ||
| async searchDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.search(request); | ||
| } | ||
| /** | ||
| * Build an injection-ready context package from a scoped request. | ||
| * Provider must implement the `package` extension. | ||
| */ | ||
| async package(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Package without application-layer gating. | ||
| */ | ||
| async packageDirect(request) { | ||
| this.assertInitialized(); | ||
| return this.service.package(request); | ||
| } | ||
| /** | ||
| * Fetch a single memory by reference. | ||
| */ | ||
| async get(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.get(ref); | ||
| } | ||
| /** | ||
| * Delete a single memory by reference. | ||
| */ | ||
| async delete(ref) { | ||
| this.assertInitialized(); | ||
| return this.service.delete(ref); | ||
| } | ||
| /** | ||
| * List memories within a scope. | ||
| */ | ||
| async list(request) { | ||
| this.assertInitialized(); | ||
| return this.service.list(request); | ||
| } | ||
| /** | ||
| * Report the capability surface of the default (or named) provider. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| */ | ||
| capabilities(providerName) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(providerName).capabilities(); | ||
| } | ||
| /** | ||
| * Resolve a named extension on the default (or named) provider. | ||
| * Returns `undefined` when the provider does not advertise the | ||
| * extension. | ||
| * | ||
| * @throws if the named provider is unknown or not initialized. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const pkg = memory.getExtension<Packager>('package'); | ||
| * ``` | ||
| */ | ||
| getExtension(extensionName, providerName) { | ||
| this.assertInitialized(); | ||
| const provider = this.service.getProvider(providerName); | ||
| return provider.getExtension?.(extensionName); | ||
| } | ||
| /** | ||
| * Aggregate status of all configured providers. Never throws: | ||
| * uninitialized providers report `initialized: false` and | ||
| * `capabilities: null`. | ||
| */ | ||
| getProviderStatus() { | ||
| const configured = this.service.getConfiguredProviders(); | ||
| const available = new Set(this.service.getAvailableProviders()); | ||
| return configured.map((name) => { | ||
| if (!available.has(name)) { | ||
| return { name, initialized: false, capabilities: null }; | ||
| } | ||
| return { | ||
| name, | ||
| initialized: true, | ||
| capabilities: this.service.getProvider(name).capabilities() | ||
| }; | ||
| }); | ||
| } | ||
| /** | ||
| * Access the full AtomicMemory namespace handle (lifecycle, audit, | ||
| * lessons, config, agents). Returns `undefined` when the client is | ||
| * not yet initialized, the `atomicmemory` provider was not included | ||
| * in the `providers` config, or that provider does not advertise the | ||
| * namespace handle. This getter intentionally never throws — callers | ||
| * can guard with a truthy check and let the handle's own methods | ||
| * raise if used incorrectly. | ||
| */ | ||
| get atomicmemory() { | ||
| if (!this.initialized) return void 0; | ||
| if (!this.service.getConfiguredProviders().includes("atomicmemory")) { | ||
| return void 0; | ||
| } | ||
| const provider = this.service.getProvider("atomicmemory"); | ||
| return provider.getExtension?.("atomicmemory.base"); | ||
| } | ||
| /** | ||
| * Low-level escape hatch for callers that need the concrete provider. | ||
| */ | ||
| getProvider(name) { | ||
| this.assertInitialized(); | ||
| return this.service.getProvider(name); | ||
| } | ||
| assertInitialized() { | ||
| if (!this.initialized) { | ||
| throw new Error( | ||
| "MemoryClient is not initialized. Call `await client.initialize()` first." | ||
| ); | ||
| } | ||
| } | ||
| }; | ||
| function pickFirstProviderKey(providers) { | ||
| for (const [key, value] of Object.entries(providers)) { | ||
| if (value !== void 0 && key !== "default") return key; | ||
| } | ||
| return void 0; | ||
| } | ||
| exports.MemoryClient = MemoryClient; | ||
| //# sourceMappingURL=chunk-GSRHENFD.cjs.map | ||
| //# sourceMappingURL=chunk-GSRHENFD.cjs.map |
| {"version":3,"sources":["../src/memory/providers/registry.ts","../src/memory/memory-service.ts","../src/client/memory-client.ts"],"names":["AtomicMemoryProvider","Mem0Provider","HindsightProvider","noopMemoryPipeline","result","UnsupportedOperationError"],"mappings":";;;;;AAoBO,IAAM,eAAA,GAAoC;AAAA,EAC/C,YAAA,EAAc,CAAC,MAAA,MAAoE;AAAA,IACjF,QAAA,EAAU,IAAIA,sCAAA,CAAqB,MAAM;AAAA,GAC3C,CAAA;AAAA,EACA,IAAA,EAAM,CAAC,MAAA,MAA4D;AAAA,IACjE,QAAA,EAAU,IAAIC,8BAAA,CAAa,MAAM;AAAA,GACnC,CAAA;AAAA,EACA,SAAA,EAAW,CAAC,MAAA,MAAiE;AAAA,IAC3E,QAAA,EAAU,IAAIC,mCAAA,CAAkB,MAAM;AAAA,GACxC;AACF,CAAA;;;ACIO,IAAM,gBAAN,MAAoB;AAAA,EAKzB,YAA6B,MAAA,EAA6B;AAA7B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAC3B,IAAA,IAAA,CAAK,sBAAsB,MAAA,CAAO,eAAA;AAAA,EACpC;AAAA,EAF6B,MAAA;AAAA,EAJrB,SAAA,uBAAgB,GA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,GAA0B;AAChC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACrB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,qBAAqB,SAAA,EAAwD;AACpF,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,SAAS,CAAA,EAAG;AACpD,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,GAAA,KAAQ,SAAA,EAAW,OAAO,GAAA;AAAA,EACvD;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-GSRHENFD.cjs","sourcesContent":["/**\n * @file Memory Provider Registry\n *\n * Maps provider names to factory functions that create\n * MemoryProviderRegistration instances from configuration.\n */\n\nimport type { MemoryProviderRegistration } from '../registration';\nimport type { AtomicMemoryProviderConfig } from '../atomicmemory-provider/types';\nimport { AtomicMemoryProvider } from '../atomicmemory-provider/atomicmemory-provider';\nimport type { Mem0ProviderConfig } from '../mem0-provider/types';\nimport { Mem0Provider } from '../mem0-provider/mem0-provider';\nimport type { HindsightProviderConfig } from '../hindsight-provider/types';\nimport { HindsightProvider } from '../hindsight-provider/hindsight-provider';\n\nexport type ProviderRegistry = Record<\n string,\n (config: any) => MemoryProviderRegistration\n>;\n\nexport const defaultRegistry: ProviderRegistry = {\n atomicmemory: (config: AtomicMemoryProviderConfig): MemoryProviderRegistration => ({\n provider: new AtomicMemoryProvider(config),\n }),\n mem0: (config: Mem0ProviderConfig): MemoryProviderRegistration => ({\n provider: new Mem0Provider(config),\n }),\n hindsight: (config: HindsightProviderConfig): MemoryProviderRegistration => ({\n provider: new HindsightProvider(config),\n }),\n};\n","/**\n * @file Memory Service\n *\n * Replaces UnifiedContextService. Routes operations to the correct\n * provider and applies optional processing pipelines.\n */\n\nimport type { MemoryProvider, Packager } from './provider';\nimport type { MemoryProcessingPipeline } from './pipeline';\nimport { noopMemoryPipeline } from './pipeline';\nimport type { MemoryProviderRegistration } from './registration';\nimport { UnsupportedOperationError } from './errors';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n} from './types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from './providers/registry';\n\nexport interface MemoryServiceConfig {\n defaultProvider: string;\n providerConfigs: Record<string, unknown>;\n}\n\nexport class MemoryService {\n private providers = new Map<string, MemoryProvider>();\n private pipelines = new Map<string, MemoryProcessingPipeline>();\n private defaultProviderName: string;\n\n constructor(private readonly config: MemoryServiceConfig) {\n this.defaultProviderName = config.defaultProvider;\n }\n\n async initialize(\n registry: ProviderRegistry = defaultRegistry\n ): Promise<void> {\n for (const [name, providerConfig] of Object.entries(\n this.config.providerConfigs\n )) {\n const factory = registry[name];\n if (!factory) continue;\n const registration: MemoryProviderRegistration = factory(providerConfig);\n this.providers.set(name, registration.provider);\n this.pipelines.set(\n name,\n registration.pipeline ?? noopMemoryPipeline\n );\n\n if (registration.provider.initialize) {\n await registration.provider.initialize();\n }\n }\n }\n\n getProvider(name?: string): MemoryProvider {\n const providerName = name ?? this.defaultProviderName;\n const provider = this.providers.get(providerName);\n if (!provider) {\n throw new Error(\n `Provider \"${providerName}\" is not registered`\n );\n }\n return provider;\n }\n\n getAvailableProviders(): string[] {\n return Array.from(this.providers.keys());\n }\n\n /**\n * Provider names declared in the SDK configuration, regardless of whether\n * they have been initialized yet. Useful for UI and getter paths that\n * need to advertise capabilities before `initialize()` has run.\n */\n getConfiguredProviders(): string[] {\n return Object.keys(this.config.providerConfigs);\n }\n\n // -----------------------------------------------------------------------\n // Core operations\n // -----------------------------------------------------------------------\n\n async ingest(\n input: IngestInput,\n providerName?: string\n ): Promise<IngestResult> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n if (pipeline.preprocessIngest) {\n const inputs = await pipeline.preprocessIngest(input);\n const results: IngestResult[] = [];\n for (const i of inputs) {\n const result = await provider.ingest(i);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, i);\n }\n results.push(result);\n }\n return mergeIngestResults(results);\n }\n\n const result = await provider.ingest(input);\n if (pipeline.postprocessIngest) {\n await pipeline.postprocessIngest(result, input);\n }\n return result;\n }\n\n async search(\n request: SearchRequest,\n providerName?: string\n ): Promise<SearchResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRequest = pipeline.preprocessSearch\n ? await pipeline.preprocessSearch(request)\n : request;\n\n const page = await provider.search(processedRequest);\n\n return pipeline.postprocessSearch\n ? await pipeline.postprocessSearch(page, processedRequest)\n : page;\n }\n\n async get(\n ref: MemoryRef,\n providerName?: string\n ): Promise<Memory | null> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const processedRef = pipeline.preprocessGet\n ? await pipeline.preprocessGet(ref)\n : ref;\n\n const memory = await provider.get(processedRef);\n\n return pipeline.postprocessGet\n ? await pipeline.postprocessGet(memory, processedRef)\n : memory;\n }\n\n async delete(\n ref: MemoryRef,\n providerName?: string\n ): Promise<void> {\n const provider = this.getProvider(providerName);\n await provider.delete(ref);\n }\n\n async list(\n request: ListRequest,\n providerName?: string\n ): Promise<ListResultPage> {\n const provider = this.getProvider(providerName);\n const pipeline = this.getPipeline(providerName);\n\n const page = await provider.list(request);\n\n return pipeline.postprocessList\n ? await pipeline.postprocessList(page, request)\n : page;\n }\n\n async package(\n request: PackageRequest,\n providerName?: string\n ): Promise<ContextPackage> {\n const provider = this.getProvider(providerName);\n const packager = provider.getExtension?.<Packager>('package');\n if (!packager) {\n throw new UnsupportedOperationError(\n provider.name,\n 'package'\n );\n }\n return packager.package(request);\n }\n\n // -----------------------------------------------------------------------\n // Internals\n // -----------------------------------------------------------------------\n\n private getPipeline(\n name?: string\n ): MemoryProcessingPipeline {\n const providerName = name ?? this.defaultProviderName;\n return (\n this.pipelines.get(providerName) ?? noopMemoryPipeline\n );\n }\n}\n\nfunction mergeIngestResults(\n results: IngestResult[]\n): IngestResult {\n return {\n created: results.flatMap((r) => r.created),\n updated: results.flatMap((r) => r.updated),\n unchanged: results.flatMap((r) => r.unchanged),\n };\n}\n","/**\n * @file MemoryClient — primary public API for the memory-layer SDK\n *\n * Pure memory operations: ingest, search, package, list, get, delete,\n * capability inspection, and provider namespace handles. No policy\n * gating, no platform/targetDomain parameters — applications that need\n * those layer them on top of this client.\n */\n\nimport { MemoryService } from '../memory/memory-service';\nimport type { MemoryProvider } from '../memory/provider';\nimport type { AtomicMemoryProviderConfig } from '../memory/atomicmemory-provider/types';\nimport type { AtomicMemoryHandle } from '../memory/atomicmemory-provider/handle';\nimport type { Mem0ProviderConfig } from '../memory/mem0-provider/types';\nimport type { HindsightProviderConfig } from '../memory/hindsight-provider/types';\nimport type {\n IngestInput,\n IngestResult,\n SearchRequest,\n SearchResultPage,\n MemoryRef,\n Memory,\n ListRequest,\n ListResultPage,\n PackageRequest,\n ContextPackage,\n Capabilities,\n} from '../memory/types';\nimport {\n defaultRegistry,\n type ProviderRegistry,\n} from '../memory/providers/registry';\n\n/**\n * Provider configuration map. Each key names a provider; the value is\n * that provider's configuration object.\n */\nexport interface MemoryProviderConfigs {\n atomicmemory?: AtomicMemoryProviderConfig;\n mem0?: Mem0ProviderConfig;\n hindsight?: HindsightProviderConfig;\n [providerName: string]: unknown;\n}\n\n/**\n * MemoryClient configuration.\n */\nexport interface MemoryClientConfig {\n /** Provider configurations keyed by provider name. */\n providers: MemoryProviderConfigs;\n /** Name of the default provider. If omitted, the first configured provider wins. */\n defaultProvider?: string;\n}\n\n/**\n * Status summary for each configured provider.\n */\nexport interface ProviderStatus {\n name: string;\n initialized: boolean;\n capabilities: Capabilities | null;\n}\n\n/**\n * MemoryClient — pure memory-layer API.\n *\n * @example\n * ```ts\n * const memory = new MemoryClient({\n * providers: { atomicmemory: { apiUrl: 'http://localhost:3050' } },\n * });\n * await memory.initialize();\n * await memory.ingest({ mode: 'text', content: 'hi', scope: { user: 'u1' } });\n * const results = await memory.search({ query: 'hi', scope: { user: 'u1' } });\n * ```\n */\nexport class MemoryClient {\n private readonly service: MemoryService;\n private initialized = false;\n\n constructor(config: MemoryClientConfig) {\n const providerConfigs: Record<string, unknown> = { ...config.providers };\n const defaultProvider =\n config.defaultProvider ?? pickFirstProviderKey(providerConfigs);\n\n if (!defaultProvider) {\n throw new Error(\n 'MemoryClient requires at least one provider config. ' +\n 'Pass e.g. { providers: { atomicmemory: { apiUrl: \"...\" } } }.'\n );\n }\n\n this.service = new MemoryService({\n defaultProvider,\n providerConfigs,\n });\n }\n\n /**\n * Initialize all configured providers. Must be called before any\n * memory operation. Idempotent.\n */\n async initialize(registry: ProviderRegistry = defaultRegistry): Promise<void> {\n if (this.initialized) return;\n await this.service.initialize(registry);\n this.initialized = true;\n }\n\n /**\n * Write memory(ies). Input supports `text`, `messages`, or `memory` modes.\n */\n async ingest(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Ingest without any application-layer gating. Equivalent to `ingest()`\n * on the core client; application wrappers override the gated variant\n * while delegating this path straight through.\n */\n async ingestDirect(input: IngestInput): Promise<IngestResult> {\n this.assertInitialized();\n return this.service.ingest(input);\n }\n\n /**\n * Search for memories matching the request.\n */\n async search(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Search without application-layer gating. See `ingestDirect` for the\n * rationale.\n */\n async searchDirect(request: SearchRequest): Promise<SearchResultPage> {\n this.assertInitialized();\n return this.service.search(request);\n }\n\n /**\n * Build an injection-ready context package from a scoped request.\n * Provider must implement the `package` extension.\n */\n async package(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Package without application-layer gating.\n */\n async packageDirect(request: PackageRequest): Promise<ContextPackage> {\n this.assertInitialized();\n return this.service.package(request);\n }\n\n /**\n * Fetch a single memory by reference.\n */\n async get(ref: MemoryRef): Promise<Memory | null> {\n this.assertInitialized();\n return this.service.get(ref);\n }\n\n /**\n * Delete a single memory by reference.\n */\n async delete(ref: MemoryRef): Promise<void> {\n this.assertInitialized();\n return this.service.delete(ref);\n }\n\n /**\n * List memories within a scope.\n */\n async list(request: ListRequest): Promise<ListResultPage> {\n this.assertInitialized();\n return this.service.list(request);\n }\n\n /**\n * Report the capability surface of the default (or named) provider.\n *\n * @throws if the named provider is unknown or not initialized.\n */\n capabilities(providerName?: string): Capabilities {\n this.assertInitialized();\n return this.service.getProvider(providerName).capabilities();\n }\n\n /**\n * Resolve a named extension on the default (or named) provider.\n * Returns `undefined` when the provider does not advertise the\n * extension.\n *\n * @throws if the named provider is unknown or not initialized.\n *\n * @example\n * ```ts\n * const pkg = memory.getExtension<Packager>('package');\n * ```\n */\n getExtension<T>(extensionName: string, providerName?: string): T | undefined {\n this.assertInitialized();\n const provider = this.service.getProvider(providerName);\n return provider.getExtension?.<T>(extensionName);\n }\n\n /**\n * Aggregate status of all configured providers. Never throws:\n * uninitialized providers report `initialized: false` and\n * `capabilities: null`.\n */\n getProviderStatus(): ProviderStatus[] {\n const configured = this.service.getConfiguredProviders();\n const available = new Set(this.service.getAvailableProviders());\n return configured.map((name) => {\n if (!available.has(name)) {\n return { name, initialized: false, capabilities: null };\n }\n return {\n name,\n initialized: true,\n capabilities: this.service.getProvider(name).capabilities(),\n };\n });\n }\n\n /**\n * Access the full AtomicMemory namespace handle (lifecycle, audit,\n * lessons, config, agents). Returns `undefined` when the client is\n * not yet initialized, the `atomicmemory` provider was not included\n * in the `providers` config, or that provider does not advertise the\n * namespace handle. This getter intentionally never throws — callers\n * can guard with a truthy check and let the handle's own methods\n * raise if used incorrectly.\n */\n get atomicmemory(): AtomicMemoryHandle | undefined {\n if (!this.initialized) return undefined;\n if (!this.service.getConfiguredProviders().includes('atomicmemory')) {\n return undefined;\n }\n const provider = this.service.getProvider('atomicmemory');\n return provider.getExtension?.<AtomicMemoryHandle>('atomicmemory.base');\n }\n\n /**\n * Low-level escape hatch for callers that need the concrete provider.\n */\n getProvider(name?: string): MemoryProvider {\n this.assertInitialized();\n return this.service.getProvider(name);\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'MemoryClient is not initialized. Call `await client.initialize()` first.'\n );\n }\n }\n}\n\nfunction pickFirstProviderKey(providers: Record<string, unknown>): string | undefined {\n for (const [key, value] of Object.entries(providers)) {\n if (value !== undefined && key !== 'default') return key;\n }\n return undefined;\n}\n"]} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2677576
042
-2.33%