@agent-receipts/dashboard 0.2.11 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/standalone/apps/web/.next/BUILD_ID +1 -1
- package/standalone/apps/web/.next/app-build-manifest.json +235 -158
- package/standalone/apps/web/.next/app-path-routes-manifest.json +21 -11
- package/standalone/apps/web/.next/build-manifest.json +13 -13
- package/standalone/apps/web/.next/prerender-manifest.json +72 -24
- package/standalone/apps/web/.next/routes-manifest.json +36 -0
- package/standalone/apps/web/.next/server/app/_not-found/page.js +2 -2
- package/standalone/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/_not-found.html +2 -2
- package/standalone/apps/web/.next/server/app/_not-found.rsc +3 -3
- package/standalone/apps/web/.next/server/app/agents/[id]/page.js +2 -2
- package/standalone/apps/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/agents/page.js +2 -2
- package/standalone/apps/web/.next/server/app/agents/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/agents.html +2 -2
- package/standalone/apps/web/.next/server/app/agents.rsc +4 -4
- package/standalone/apps/web/.next/server/app/api/agents/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/chains/[id]/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/chains/[id]/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/chains/[id]/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/cleanup/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/cleanup/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/config/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/config/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/config/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/invoices/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/invoices/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/invoices/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/judgments/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/judgments/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/judgments/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/memory/audit/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/audit/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/audit/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/[id]/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/[id]/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/[id]/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/entities/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/forget/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/forget/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/forget/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/observe/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/observe/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/observe/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/provenance/[obsId]/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/provenance/[obsId]/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/provenance/[obsId]/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/recall/route.js +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/recall/route.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/api/memory/recall/route_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/api/receipts/[id]/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/receipts/[id]/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/receipts/[id]/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/receipts/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/receipts/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/receipts/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/search/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/search/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/stats/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/stats/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/stats/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/api/verify/route.js +1 -1
- package/standalone/apps/web/.next/server/app/api/verify/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/api/verify/route_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/chains/[id]/page.js +2 -2
- package/standalone/apps/web/.next/server/app/chains/[id]/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/chains/[id]/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/chains/page.js +2 -2
- package/standalone/apps/web/.next/server/app/chains/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/chains/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/chains.html +2 -2
- package/standalone/apps/web/.next/server/app/chains.rsc +4 -4
- package/standalone/apps/web/.next/server/app/constraints/page.js +2 -2
- package/standalone/apps/web/.next/server/app/constraints/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/constraints/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/constraints.html +2 -2
- package/standalone/apps/web/.next/server/app/constraints.rsc +4 -4
- package/standalone/apps/web/.next/server/app/get-started/page.js +2 -2
- package/standalone/apps/web/.next/server/app/get-started/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/get-started/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/get-started.html +3 -3
- package/standalone/apps/web/.next/server/app/get-started.rsc +4 -4
- package/standalone/apps/web/.next/server/app/how-it-works/page.js +2 -2
- package/standalone/apps/web/.next/server/app/how-it-works/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/how-it-works/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/how-it-works.html +3 -3
- package/standalone/apps/web/.next/server/app/how-it-works.rsc +4 -4
- package/standalone/apps/web/.next/server/app/icon.svg/route.js +1 -1
- package/standalone/apps/web/.next/server/app/icon.svg/route.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/index.html +2 -2
- package/standalone/apps/web/.next/server/app/index.rsc +4 -4
- package/standalone/apps/web/.next/server/app/invoices/page.js +2 -2
- package/standalone/apps/web/.next/server/app/invoices/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/invoices/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/invoices.html +3 -3
- package/standalone/apps/web/.next/server/app/invoices.rsc +4 -4
- package/standalone/apps/web/.next/server/app/judgments/page.js +2 -2
- package/standalone/apps/web/.next/server/app/judgments/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/judgments/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/judgments.html +2 -2
- package/standalone/apps/web/.next/server/app/judgments.rsc +4 -4
- package/standalone/apps/web/.next/server/app/memory/[entityId]/page.js +2 -0
- package/standalone/apps/web/.next/server/app/memory/[entityId]/page.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/memory/[entityId]/page_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/memory/audit/page.js +2 -0
- package/standalone/apps/web/.next/server/app/memory/audit/page.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/memory/audit/page_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/memory/audit.html +9 -0
- package/standalone/apps/web/.next/server/app/memory/audit.meta +7 -0
- package/standalone/apps/web/.next/server/app/memory/audit.rsc +21 -0
- package/standalone/apps/web/.next/server/app/memory/page.js +2 -0
- package/standalone/apps/web/.next/server/app/memory/page.js.nft.json +1 -0
- package/standalone/apps/web/.next/server/app/memory/page_client-reference-manifest.js +1 -0
- package/standalone/apps/web/.next/server/app/memory.html +9 -0
- package/standalone/apps/web/.next/server/app/memory.meta +7 -0
- package/standalone/apps/web/.next/server/app/memory.rsc +21 -0
- package/standalone/apps/web/.next/server/app/page.js +2 -2
- package/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/receipts/[id]/page.js +2 -2
- package/standalone/apps/web/.next/server/app/receipts/[id]/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/receipts/[id]/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/receipts/page.js +2 -2
- package/standalone/apps/web/.next/server/app/receipts/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/receipts/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/receipts.html +2 -2
- package/standalone/apps/web/.next/server/app/receipts.rsc +4 -4
- package/standalone/apps/web/.next/server/app/settings/page.js +2 -2
- package/standalone/apps/web/.next/server/app/settings/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/settings.html +2 -2
- package/standalone/apps/web/.next/server/app/settings.rsc +4 -4
- package/standalone/apps/web/.next/server/app/verify/page.js +2 -2
- package/standalone/apps/web/.next/server/app/verify/page.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/app/verify/page_client-reference-manifest.js +1 -1
- package/standalone/apps/web/.next/server/app/verify.html +2 -2
- package/standalone/apps/web/.next/server/app/verify.rsc +4 -4
- package/standalone/apps/web/.next/server/app-paths-manifest.json +21 -11
- package/standalone/apps/web/.next/server/chunks/1725.js +1 -0
- package/standalone/apps/web/.next/server/chunks/4099.js +1 -0
- package/standalone/apps/web/.next/server/chunks/4236.js +1 -0
- package/standalone/apps/web/.next/server/chunks/4319.js +1 -0
- package/standalone/apps/web/.next/server/chunks/4640.js +8 -0
- package/standalone/apps/web/.next/server/chunks/4886.js +1 -0
- package/standalone/apps/web/.next/server/chunks/578.js +1 -1
- package/standalone/apps/web/.next/server/chunks/5783.js +6 -0
- package/standalone/apps/web/.next/server/chunks/6568.js +1 -0
- package/standalone/apps/web/.next/server/chunks/6803.js +345 -0
- package/standalone/apps/web/.next/server/chunks/6872.js +1 -0
- package/standalone/apps/web/.next/server/chunks/{955.js → 7955.js} +1 -1
- package/standalone/apps/web/.next/server/chunks/808.js +1 -0
- package/standalone/apps/web/.next/server/chunks/9295.js +9 -0
- package/standalone/apps/web/.next/server/middleware-build-manifest.js +1 -1
- package/standalone/apps/web/.next/server/pages/404.html +2 -2
- package/standalone/apps/web/.next/server/pages/500.html +1 -1
- package/standalone/apps/web/.next/server/pages/_document.js +1 -1
- package/standalone/apps/web/.next/server/pages/_document.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/pages/_error.js +2 -2
- package/standalone/apps/web/.next/server/pages/_error.js.nft.json +1 -1
- package/standalone/apps/web/.next/server/webpack-runtime.js +1 -1
- package/standalone/apps/web/.next/static/chunks/1577-52a37d87918977e4.js +1 -0
- package/standalone/apps/web/.next/static/chunks/2702-4afe85cf1319178b.js +1 -0
- package/standalone/apps/web/.next/static/chunks/5388-497db038071971af.js +1 -0
- package/standalone/apps/web/.next/static/chunks/5935-25e4517f9bfb3e54.js +1 -0
- package/standalone/apps/web/.next/static/chunks/7493-21c65d3cf41d96fa.js +1 -0
- package/standalone/apps/web/.next/static/chunks/9743-b93c9a67bf15f28e.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/_not-found/page-dfe859f15ff21004.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/agents/[id]/page-bd27daddc88ea13c.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/agents/page-67d8a1e928ffad08.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/agents/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/chains/[id]/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/cleanup/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/config/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/invoices/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/judgments/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/audit/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/entities/[id]/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/entities/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/forget/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/observe/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/provenance/[obsId]/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/memory/recall/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/receipts/[id]/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/receipts/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/search/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/stats/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/api/verify/route-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/chains/[id]/page-45d744cdd6495e6b.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/chains/page-bd595389b36e9ec3.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/constraints/page-d814c6768a5ac3cd.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/get-started/layout-08c70580b96dfffc.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/get-started/page-3f1e33bbce2134ae.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/how-it-works/page-fd39b30017b3bb8f.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/invoices/page-9923d5bbee5a89c9.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/judgments/page-dd290557c6948b22.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/layout-34e5620f9fbf2601.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/memory/[entityId]/page-6faf1a99bcc27c06.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/memory/audit/page-276a1a1a5423380f.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/memory/page-e20ae73fade64e1c.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/page-b758df33c161f189.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/receipts/[id]/page-3b95a98a03395684.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/receipts/page-665b6e374ca41d0c.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/settings/page-a775a2f3752a1cdd.js +1 -0
- package/standalone/apps/web/.next/static/chunks/app/verify/page-7a654fc6b29b44a8.js +1 -0
- package/standalone/apps/web/.next/static/chunks/framework-6c19635498a17075.js +1 -0
- package/standalone/apps/web/.next/static/chunks/main-07cb75c461ef6926.js +1 -0
- package/standalone/apps/web/.next/static/chunks/main-app-5ae62731e5401157.js +1 -0
- package/standalone/apps/web/.next/static/chunks/pages/{_app-0277c84f8b0dbf6c.js → _app-b8da3f21cdb968e8.js} +1 -1
- package/standalone/apps/web/.next/static/chunks/pages/_error-797d67047bd0e506.js +1 -0
- package/standalone/apps/web/.next/static/chunks/{webpack-acfef48110e09a0e.js → webpack-631fa6a7d974b7cd.js} +1 -1
- package/standalone/apps/web/.next/static/css/90a952694ea5745a.css +5 -0
- package/standalone/apps/web/.next/static/nfGBKWJnAAcZ1it0v5lJ4/_buildManifest.js +1 -0
- package/standalone/apps/web/src/lib/demo-memory-store.ts +238 -0
- package/standalone/apps/web/src/lib/sdk-server.ts +24 -1
- package/standalone/node_modules/.pnpm/postcss@8.4.31/node_modules/postcss/package.json +0 -0
- package/standalone/packages/crypto/package.json +1 -1
- package/standalone/packages/mcp-server/dist/index.js +827 -0
- package/standalone/packages/mcp-server/package.json +1 -1
- package/standalone/apps/web/.next/server/chunks/236.js +0 -1
- package/standalone/apps/web/.next/server/chunks/319.js +0 -1
- package/standalone/apps/web/.next/server/chunks/568.js +0 -1
- package/standalone/apps/web/.next/server/chunks/640.js +0 -8
- package/standalone/apps/web/.next/server/chunks/718.js +0 -9
- package/standalone/apps/web/.next/server/chunks/783.js +0 -6
- package/standalone/apps/web/.next/server/chunks/798.js +0 -1
- package/standalone/apps/web/.next/server/chunks/803.js +0 -189
- package/standalone/apps/web/.next/server/chunks/872.js +0 -1
- package/standalone/apps/web/.next/server/chunks/99.js +0 -1
- package/standalone/apps/web/.next/static/_nYBCMM2RKAoZB_aY16vH/_buildManifest.js +0 -1
- package/standalone/apps/web/.next/static/chunks/388-350fe7358149b937.js +0 -1
- package/standalone/apps/web/.next/static/chunks/493-829b6213ada29da8.js +0 -1
- package/standalone/apps/web/.next/static/chunks/577-d18d2ca2465d6f72.js +0 -1
- package/standalone/apps/web/.next/static/chunks/702-fda62c486b5bb5f8.js +0 -1
- package/standalone/apps/web/.next/static/chunks/743-1f01386e3a1c3b1c.js +0 -1
- package/standalone/apps/web/.next/static/chunks/935-f80c248ba99512e2.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/_not-found/page-d6caa906bf90ce7d.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/agents/[id]/page-fe1560a72adbddc7.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/agents/page-ab0dfc5113e3ab45.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/agents/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/chains/[id]/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/cleanup/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/config/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/invoices/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/judgments/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/receipts/[id]/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/receipts/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/search/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/stats/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/api/verify/route-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/chains/[id]/page-ba935d4fadcbc557.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/chains/page-a3f21d8d62ffa174.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/constraints/page-ebfd1721530940c7.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/get-started/layout-3752a720184a6696.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/get-started/page-72febd5ba59689bb.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/how-it-works/page-46a028e3d817a15f.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/invoices/page-71a064dd2e94a214.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/judgments/page-5062f4bb5a918305.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/layout-43fe6d25823e2373.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/page-deece9e5e4e6c9dc.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/receipts/[id]/page-024badaf0b4aa9db.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/receipts/page-dfc039aadf7a6869.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/settings/page-1f33c77dcca141ce.js +0 -1
- package/standalone/apps/web/.next/static/chunks/app/verify/page-1631d147709caa76.js +0 -1
- package/standalone/apps/web/.next/static/chunks/framework-b712132b711b77b2.js +0 -1
- package/standalone/apps/web/.next/static/chunks/main-3cf37cd4e8f17e4b.js +0 -1
- package/standalone/apps/web/.next/static/chunks/main-app-d3c171e7aef05d2f.js +0 -1
- package/standalone/apps/web/.next/static/chunks/pages/_error-5420f4ec91760914.js +0 -1
- package/standalone/apps/web/.next/static/css/b5d5599054174bf1.css +0 -5
- /package/standalone/apps/web/.next/static/{_nYBCMM2RKAoZB_aY16vH → nfGBKWJnAAcZ1it0v5lJ4}/_ssgManifest.js +0 -0
|
@@ -135,6 +135,9 @@ var SqliteReceiptStore = class {
|
|
|
135
135
|
data: JSON.stringify(receipt)
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
+
getDb() {
|
|
139
|
+
return this.db;
|
|
140
|
+
}
|
|
138
141
|
async save(receipt) {
|
|
139
142
|
const row = this.toRow(receipt);
|
|
140
143
|
this.db.prepare(`INSERT OR REPLACE INTO receipts (
|
|
@@ -474,6 +477,583 @@ var ConfigManager = class {
|
|
|
474
477
|
}
|
|
475
478
|
};
|
|
476
479
|
|
|
480
|
+
// src/storage/memory-store.ts
|
|
481
|
+
var CONFIDENCE_ORDER = {
|
|
482
|
+
certain: 5,
|
|
483
|
+
high: 4,
|
|
484
|
+
medium: 3,
|
|
485
|
+
low: 2,
|
|
486
|
+
deprecated: 1
|
|
487
|
+
};
|
|
488
|
+
var MemoryStore = class {
|
|
489
|
+
constructor(db) {
|
|
490
|
+
this.db = db;
|
|
491
|
+
}
|
|
492
|
+
init() {
|
|
493
|
+
this.db.exec(`
|
|
494
|
+
CREATE TABLE IF NOT EXISTS entities (
|
|
495
|
+
entity_id TEXT PRIMARY KEY,
|
|
496
|
+
entity_type TEXT NOT NULL,
|
|
497
|
+
name TEXT NOT NULL,
|
|
498
|
+
aliases TEXT NOT NULL DEFAULT '[]',
|
|
499
|
+
scope TEXT NOT NULL DEFAULT 'agent',
|
|
500
|
+
created_at TEXT NOT NULL,
|
|
501
|
+
created_by_agent TEXT NOT NULL,
|
|
502
|
+
created_by_receipt TEXT NOT NULL,
|
|
503
|
+
forgotten_at TEXT,
|
|
504
|
+
merged_into TEXT,
|
|
505
|
+
attributes TEXT NOT NULL DEFAULT '{}',
|
|
506
|
+
metadata TEXT NOT NULL DEFAULT '{}'
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
CREATE INDEX IF NOT EXISTS idx_entities_type ON entities(entity_type);
|
|
510
|
+
CREATE INDEX IF NOT EXISTS idx_entities_name ON entities(name);
|
|
511
|
+
CREATE INDEX IF NOT EXISTS idx_entities_scope ON entities(scope);
|
|
512
|
+
CREATE INDEX IF NOT EXISTS idx_entities_agent ON entities(created_by_agent);
|
|
513
|
+
CREATE INDEX IF NOT EXISTS idx_entities_forgotten ON entities(forgotten_at);
|
|
514
|
+
|
|
515
|
+
CREATE TABLE IF NOT EXISTS observations (
|
|
516
|
+
observation_id TEXT PRIMARY KEY,
|
|
517
|
+
entity_id TEXT NOT NULL,
|
|
518
|
+
content TEXT NOT NULL,
|
|
519
|
+
confidence TEXT NOT NULL DEFAULT 'medium',
|
|
520
|
+
source_receipt_id TEXT NOT NULL,
|
|
521
|
+
source_agent_id TEXT NOT NULL,
|
|
522
|
+
source_context TEXT,
|
|
523
|
+
observed_at TEXT NOT NULL,
|
|
524
|
+
forgotten_at TEXT,
|
|
525
|
+
forgotten_by TEXT,
|
|
526
|
+
superseded_by TEXT,
|
|
527
|
+
expires_at TEXT,
|
|
528
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
529
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
530
|
+
FOREIGN KEY (entity_id) REFERENCES entities(entity_id)
|
|
531
|
+
);
|
|
532
|
+
|
|
533
|
+
CREATE INDEX IF NOT EXISTS idx_obs_entity ON observations(entity_id);
|
|
534
|
+
CREATE INDEX IF NOT EXISTS idx_obs_agent ON observations(source_agent_id);
|
|
535
|
+
CREATE INDEX IF NOT EXISTS idx_obs_confidence ON observations(confidence);
|
|
536
|
+
CREATE INDEX IF NOT EXISTS idx_obs_forgotten ON observations(forgotten_at);
|
|
537
|
+
CREATE INDEX IF NOT EXISTS idx_obs_receipt ON observations(source_receipt_id);
|
|
538
|
+
CREATE INDEX IF NOT EXISTS idx_obs_expires ON observations(expires_at);
|
|
539
|
+
|
|
540
|
+
CREATE TABLE IF NOT EXISTS relationships (
|
|
541
|
+
relationship_id TEXT PRIMARY KEY,
|
|
542
|
+
from_entity_id TEXT NOT NULL,
|
|
543
|
+
to_entity_id TEXT NOT NULL,
|
|
544
|
+
relationship_type TEXT NOT NULL,
|
|
545
|
+
strength TEXT NOT NULL DEFAULT 'medium',
|
|
546
|
+
source_receipt_id TEXT NOT NULL,
|
|
547
|
+
created_at TEXT NOT NULL,
|
|
548
|
+
forgotten_at TEXT,
|
|
549
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
550
|
+
FOREIGN KEY (from_entity_id) REFERENCES entities(entity_id),
|
|
551
|
+
FOREIGN KEY (to_entity_id) REFERENCES entities(entity_id)
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
CREATE INDEX IF NOT EXISTS idx_rel_from ON relationships(from_entity_id);
|
|
555
|
+
CREATE INDEX IF NOT EXISTS idx_rel_to ON relationships(to_entity_id);
|
|
556
|
+
CREATE INDEX IF NOT EXISTS idx_rel_type ON relationships(relationship_type);
|
|
557
|
+
`);
|
|
558
|
+
try {
|
|
559
|
+
this.db.exec("ALTER TABLE observations ADD COLUMN expires_at TEXT");
|
|
560
|
+
} catch {
|
|
561
|
+
}
|
|
562
|
+
try {
|
|
563
|
+
this.db.exec(`
|
|
564
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS observations_fts USING fts5(
|
|
565
|
+
content,
|
|
566
|
+
content='observations',
|
|
567
|
+
content_rowid='rowid',
|
|
568
|
+
tokenize='porter unicode61'
|
|
569
|
+
);
|
|
570
|
+
`);
|
|
571
|
+
} catch {
|
|
572
|
+
}
|
|
573
|
+
this.db.exec(`
|
|
574
|
+
CREATE TRIGGER IF NOT EXISTS observations_ai AFTER INSERT ON observations BEGIN
|
|
575
|
+
INSERT INTO observations_fts(rowid, content) VALUES (new.rowid, new.content);
|
|
576
|
+
END;
|
|
577
|
+
|
|
578
|
+
CREATE TRIGGER IF NOT EXISTS observations_ad AFTER DELETE ON observations BEGIN
|
|
579
|
+
INSERT INTO observations_fts(observations_fts, rowid, content) VALUES('delete', old.rowid, old.content);
|
|
580
|
+
END;
|
|
581
|
+
|
|
582
|
+
CREATE TRIGGER IF NOT EXISTS observations_au AFTER UPDATE ON observations BEGIN
|
|
583
|
+
INSERT INTO observations_fts(observations_fts, rowid, content) VALUES('delete', old.rowid, old.content);
|
|
584
|
+
INSERT INTO observations_fts(rowid, content) VALUES (new.rowid, new.content);
|
|
585
|
+
END;
|
|
586
|
+
`);
|
|
587
|
+
}
|
|
588
|
+
// --- Entities ---
|
|
589
|
+
createEntity(entity) {
|
|
590
|
+
this.db.prepare(`
|
|
591
|
+
INSERT INTO entities (entity_id, entity_type, name, aliases, scope, created_at,
|
|
592
|
+
created_by_agent, created_by_receipt, forgotten_at, merged_into, attributes, metadata)
|
|
593
|
+
VALUES (@entity_id, @entity_type, @name, @aliases, @scope, @created_at,
|
|
594
|
+
@created_by_agent, @created_by_receipt, @forgotten_at, @merged_into, @attributes, @metadata)
|
|
595
|
+
`).run({
|
|
596
|
+
entity_id: entity.entity_id,
|
|
597
|
+
entity_type: entity.entity_type,
|
|
598
|
+
name: entity.name,
|
|
599
|
+
aliases: JSON.stringify(entity.aliases),
|
|
600
|
+
scope: entity.scope,
|
|
601
|
+
created_at: entity.created_at,
|
|
602
|
+
created_by_agent: entity.created_by_agent,
|
|
603
|
+
created_by_receipt: entity.created_by_receipt,
|
|
604
|
+
forgotten_at: entity.forgotten_at,
|
|
605
|
+
merged_into: entity.merged_into,
|
|
606
|
+
attributes: JSON.stringify(entity.attributes),
|
|
607
|
+
metadata: JSON.stringify(entity.metadata)
|
|
608
|
+
});
|
|
609
|
+
return entity;
|
|
610
|
+
}
|
|
611
|
+
getEntity(entityId) {
|
|
612
|
+
const row = this.db.prepare("SELECT * FROM entities WHERE entity_id = ?").get(entityId);
|
|
613
|
+
if (!row) return null;
|
|
614
|
+
return this.rowToEntity(row);
|
|
615
|
+
}
|
|
616
|
+
findEntityByName(name, entityType) {
|
|
617
|
+
const row = this.db.prepare(
|
|
618
|
+
"SELECT * FROM entities WHERE name = ? AND entity_type = ? AND forgotten_at IS NULL AND merged_into IS NULL"
|
|
619
|
+
).get(name, entityType);
|
|
620
|
+
if (!row) return null;
|
|
621
|
+
return this.rowToEntity(row);
|
|
622
|
+
}
|
|
623
|
+
findEntities(query) {
|
|
624
|
+
const conditions = [];
|
|
625
|
+
const params = [];
|
|
626
|
+
if (!query.include_forgotten) {
|
|
627
|
+
conditions.push("forgotten_at IS NULL");
|
|
628
|
+
conditions.push("merged_into IS NULL");
|
|
629
|
+
}
|
|
630
|
+
if (query.entity_type) {
|
|
631
|
+
conditions.push("entity_type = ?");
|
|
632
|
+
params.push(query.entity_type);
|
|
633
|
+
}
|
|
634
|
+
if (query.scope) {
|
|
635
|
+
conditions.push("scope = ?");
|
|
636
|
+
params.push(query.scope);
|
|
637
|
+
}
|
|
638
|
+
if (query.agent_id) {
|
|
639
|
+
conditions.push("created_by_agent = ?");
|
|
640
|
+
params.push(query.agent_id);
|
|
641
|
+
}
|
|
642
|
+
if (query.query) {
|
|
643
|
+
conditions.push("(name LIKE ? OR aliases LIKE ?)");
|
|
644
|
+
const pattern = `%${query.query}%`;
|
|
645
|
+
params.push(pattern, pattern);
|
|
646
|
+
}
|
|
647
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
648
|
+
const limit = query.limit ?? 20;
|
|
649
|
+
const page = query.page ?? 1;
|
|
650
|
+
const offset = (page - 1) * limit;
|
|
651
|
+
const countRow = this.db.prepare(`SELECT COUNT(*) as cnt FROM entities ${where}`).get(...params);
|
|
652
|
+
const total = countRow.cnt;
|
|
653
|
+
const totalPages = Math.max(1, Math.ceil(total / limit));
|
|
654
|
+
const rows = this.db.prepare(
|
|
655
|
+
`SELECT * FROM entities ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`
|
|
656
|
+
).all(...params, limit, offset);
|
|
657
|
+
return {
|
|
658
|
+
data: rows.map((r) => this.rowToEntity(r)),
|
|
659
|
+
pagination: {
|
|
660
|
+
page,
|
|
661
|
+
limit,
|
|
662
|
+
total,
|
|
663
|
+
total_pages: totalPages,
|
|
664
|
+
has_next: page < totalPages,
|
|
665
|
+
has_prev: page > 1
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
updateEntity(entityId, updates) {
|
|
670
|
+
const existing = this.getEntity(entityId);
|
|
671
|
+
if (!existing) throw new Error(`Entity not found: ${entityId}`);
|
|
672
|
+
const updated = { ...existing, ...updates };
|
|
673
|
+
this.db.prepare(`
|
|
674
|
+
UPDATE entities SET
|
|
675
|
+
name = @name, aliases = @aliases, scope = @scope,
|
|
676
|
+
attributes = @attributes, metadata = @metadata,
|
|
677
|
+
forgotten_at = @forgotten_at, merged_into = @merged_into
|
|
678
|
+
WHERE entity_id = @entity_id
|
|
679
|
+
`).run({
|
|
680
|
+
entity_id: entityId,
|
|
681
|
+
name: updated.name,
|
|
682
|
+
aliases: JSON.stringify(updated.aliases),
|
|
683
|
+
scope: updated.scope,
|
|
684
|
+
attributes: JSON.stringify(updated.attributes),
|
|
685
|
+
metadata: JSON.stringify(updated.metadata),
|
|
686
|
+
forgotten_at: updated.forgotten_at,
|
|
687
|
+
merged_into: updated.merged_into
|
|
688
|
+
});
|
|
689
|
+
return this.getEntity(entityId);
|
|
690
|
+
}
|
|
691
|
+
forgetEntity(entityId, agentId) {
|
|
692
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
693
|
+
this.db.prepare("UPDATE entities SET forgotten_at = ? WHERE entity_id = ?").run(now, entityId);
|
|
694
|
+
this.db.prepare("UPDATE observations SET forgotten_at = ?, forgotten_by = ? WHERE entity_id = ? AND forgotten_at IS NULL").run(now, agentId, entityId);
|
|
695
|
+
}
|
|
696
|
+
mergeEntities(sourceId, targetId) {
|
|
697
|
+
const source = this.getEntity(sourceId);
|
|
698
|
+
const target = this.getEntity(targetId);
|
|
699
|
+
if (!source) throw new Error(`Source entity not found: ${sourceId}`);
|
|
700
|
+
if (!target) throw new Error(`Target entity not found: ${targetId}`);
|
|
701
|
+
this.db.prepare("UPDATE observations SET entity_id = ? WHERE entity_id = ?").run(targetId, sourceId);
|
|
702
|
+
this.db.prepare("UPDATE relationships SET from_entity_id = ? WHERE from_entity_id = ?").run(targetId, sourceId);
|
|
703
|
+
this.db.prepare("UPDATE relationships SET to_entity_id = ? WHERE to_entity_id = ?").run(targetId, sourceId);
|
|
704
|
+
const mergedAliases = [.../* @__PURE__ */ new Set([...target.aliases, source.name, ...source.aliases])];
|
|
705
|
+
this.db.prepare("UPDATE entities SET aliases = ? WHERE entity_id = ?").run(JSON.stringify(mergedAliases), targetId);
|
|
706
|
+
this.db.prepare("UPDATE entities SET merged_into = ?, forgotten_at = ? WHERE entity_id = ?").run(targetId, (/* @__PURE__ */ new Date()).toISOString(), sourceId);
|
|
707
|
+
return this.getEntity(targetId);
|
|
708
|
+
}
|
|
709
|
+
// --- Observations ---
|
|
710
|
+
addObservation(obs) {
|
|
711
|
+
this.db.prepare(`
|
|
712
|
+
INSERT INTO observations (observation_id, entity_id, content, confidence,
|
|
713
|
+
source_receipt_id, source_agent_id, source_context, observed_at,
|
|
714
|
+
forgotten_at, forgotten_by, superseded_by, expires_at, tags, metadata)
|
|
715
|
+
VALUES (@observation_id, @entity_id, @content, @confidence,
|
|
716
|
+
@source_receipt_id, @source_agent_id, @source_context, @observed_at,
|
|
717
|
+
@forgotten_at, @forgotten_by, @superseded_by, @expires_at, @tags, @metadata)
|
|
718
|
+
`).run({
|
|
719
|
+
observation_id: obs.observation_id,
|
|
720
|
+
entity_id: obs.entity_id,
|
|
721
|
+
content: obs.content,
|
|
722
|
+
confidence: obs.confidence,
|
|
723
|
+
source_receipt_id: obs.source_receipt_id,
|
|
724
|
+
source_agent_id: obs.source_agent_id,
|
|
725
|
+
source_context: obs.source_context,
|
|
726
|
+
observed_at: obs.observed_at,
|
|
727
|
+
forgotten_at: obs.forgotten_at,
|
|
728
|
+
forgotten_by: obs.forgotten_by,
|
|
729
|
+
superseded_by: obs.superseded_by,
|
|
730
|
+
expires_at: obs.expires_at ?? null,
|
|
731
|
+
tags: JSON.stringify(obs.tags),
|
|
732
|
+
metadata: JSON.stringify(obs.metadata)
|
|
733
|
+
});
|
|
734
|
+
return obs;
|
|
735
|
+
}
|
|
736
|
+
getObservation(observationId) {
|
|
737
|
+
const row = this.db.prepare("SELECT * FROM observations WHERE observation_id = ?").get(observationId);
|
|
738
|
+
if (!row) return null;
|
|
739
|
+
return this.rowToObservation(row);
|
|
740
|
+
}
|
|
741
|
+
getObservations(entityId, includeForgotten = false) {
|
|
742
|
+
const where = includeForgotten ? "WHERE entity_id = ?" : "WHERE entity_id = ? AND forgotten_at IS NULL AND (expires_at IS NULL OR expires_at > datetime('now'))";
|
|
743
|
+
const rows = this.db.prepare(
|
|
744
|
+
`SELECT * FROM observations ${where} ORDER BY observed_at DESC`
|
|
745
|
+
).all(entityId);
|
|
746
|
+
return rows.map((r) => this.rowToObservation(r));
|
|
747
|
+
}
|
|
748
|
+
forgetObservation(obsId, agentId) {
|
|
749
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
750
|
+
this.db.prepare("UPDATE observations SET forgotten_at = ?, forgotten_by = ? WHERE observation_id = ?").run(now, agentId, obsId);
|
|
751
|
+
}
|
|
752
|
+
supersede(oldObsId, newObs) {
|
|
753
|
+
this.db.prepare("UPDATE observations SET superseded_by = ? WHERE observation_id = ?").run(newObs.observation_id, oldObsId);
|
|
754
|
+
return this.addObservation(newObs);
|
|
755
|
+
}
|
|
756
|
+
// --- Relationships ---
|
|
757
|
+
addRelationship(rel) {
|
|
758
|
+
this.db.prepare(`
|
|
759
|
+
INSERT INTO relationships (relationship_id, from_entity_id, to_entity_id,
|
|
760
|
+
relationship_type, strength, source_receipt_id, created_at, forgotten_at, metadata)
|
|
761
|
+
VALUES (@relationship_id, @from_entity_id, @to_entity_id,
|
|
762
|
+
@relationship_type, @strength, @source_receipt_id, @created_at, @forgotten_at, @metadata)
|
|
763
|
+
`).run({
|
|
764
|
+
relationship_id: rel.relationship_id,
|
|
765
|
+
from_entity_id: rel.from_entity_id,
|
|
766
|
+
to_entity_id: rel.to_entity_id,
|
|
767
|
+
relationship_type: rel.relationship_type,
|
|
768
|
+
strength: rel.strength,
|
|
769
|
+
source_receipt_id: rel.source_receipt_id,
|
|
770
|
+
created_at: rel.created_at,
|
|
771
|
+
forgotten_at: rel.forgotten_at,
|
|
772
|
+
metadata: JSON.stringify(rel.metadata)
|
|
773
|
+
});
|
|
774
|
+
return rel;
|
|
775
|
+
}
|
|
776
|
+
getRelationships(entityId) {
|
|
777
|
+
const rows = this.db.prepare(
|
|
778
|
+
"SELECT * FROM relationships WHERE (from_entity_id = ? OR to_entity_id = ?) AND forgotten_at IS NULL ORDER BY created_at DESC"
|
|
779
|
+
).all(entityId, entityId);
|
|
780
|
+
return rows.map((r) => this.rowToRelationship(r));
|
|
781
|
+
}
|
|
782
|
+
forgetRelationship(relId) {
|
|
783
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
784
|
+
this.db.prepare("UPDATE relationships SET forgotten_at = ? WHERE relationship_id = ?").run(now, relId);
|
|
785
|
+
}
|
|
786
|
+
// --- Search ---
|
|
787
|
+
search(query, filters) {
|
|
788
|
+
const limit = filters?.limit ?? 20;
|
|
789
|
+
let results;
|
|
790
|
+
try {
|
|
791
|
+
const ftsRows = this.db.prepare(`
|
|
792
|
+
SELECT o.*, observations_fts.rank
|
|
793
|
+
FROM observations_fts
|
|
794
|
+
JOIN observations o ON o.rowid = observations_fts.rowid
|
|
795
|
+
WHERE observations_fts MATCH ?
|
|
796
|
+
AND o.forgotten_at IS NULL
|
|
797
|
+
AND (o.expires_at IS NULL OR o.expires_at > datetime('now'))
|
|
798
|
+
ORDER BY rank
|
|
799
|
+
LIMIT ?
|
|
800
|
+
`).all(query, limit);
|
|
801
|
+
results = ftsRows.map((row) => {
|
|
802
|
+
const obs = this.rowToObservation(row);
|
|
803
|
+
const entity = this.getEntity(obs.entity_id);
|
|
804
|
+
return {
|
|
805
|
+
entity,
|
|
806
|
+
observation: obs,
|
|
807
|
+
rank: row.rank
|
|
808
|
+
};
|
|
809
|
+
}).filter((r) => r.entity !== null);
|
|
810
|
+
} catch {
|
|
811
|
+
const likeRows = this.db.prepare(`
|
|
812
|
+
SELECT * FROM observations
|
|
813
|
+
WHERE content LIKE ? AND forgotten_at IS NULL
|
|
814
|
+
AND (expires_at IS NULL OR expires_at > datetime('now'))
|
|
815
|
+
ORDER BY observed_at DESC
|
|
816
|
+
LIMIT ?
|
|
817
|
+
`).all(`%${query}%`, limit);
|
|
818
|
+
results = likeRows.map((row, idx) => {
|
|
819
|
+
const obs = this.rowToObservation(row);
|
|
820
|
+
const entity = this.getEntity(obs.entity_id);
|
|
821
|
+
return {
|
|
822
|
+
entity,
|
|
823
|
+
observation: obs,
|
|
824
|
+
rank: idx
|
|
825
|
+
};
|
|
826
|
+
}).filter((r) => r.entity !== null);
|
|
827
|
+
}
|
|
828
|
+
if (filters?.entity_type) {
|
|
829
|
+
results = results.filter((r) => r.entity.entity_type === filters.entity_type);
|
|
830
|
+
}
|
|
831
|
+
if (filters?.scope) {
|
|
832
|
+
results = results.filter((r) => r.entity.scope === filters.scope);
|
|
833
|
+
}
|
|
834
|
+
if (filters?.confidence_min) {
|
|
835
|
+
const minOrder = CONFIDENCE_ORDER[filters.confidence_min] ?? 0;
|
|
836
|
+
results = results.filter((r) => (CONFIDENCE_ORDER[r.observation.confidence] ?? 0) >= minOrder);
|
|
837
|
+
}
|
|
838
|
+
return results;
|
|
839
|
+
}
|
|
840
|
+
recall(query) {
|
|
841
|
+
if (query.query) {
|
|
842
|
+
const results = this.search(query.query, query);
|
|
843
|
+
const entityMap = /* @__PURE__ */ new Map();
|
|
844
|
+
const observations2 = [];
|
|
845
|
+
for (const r of results) {
|
|
846
|
+
entityMap.set(r.entity.entity_id, r.entity);
|
|
847
|
+
observations2.push(r.observation);
|
|
848
|
+
}
|
|
849
|
+
return {
|
|
850
|
+
entities: Array.from(entityMap.values()),
|
|
851
|
+
observations: observations2,
|
|
852
|
+
total: observations2.length
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const entityResult = this.findEntities(query);
|
|
856
|
+
const observations = [];
|
|
857
|
+
for (const entity of entityResult.data) {
|
|
858
|
+
const obs = this.getObservations(entity.entity_id, query.include_forgotten);
|
|
859
|
+
observations.push(...obs);
|
|
860
|
+
}
|
|
861
|
+
return {
|
|
862
|
+
entities: entityResult.data,
|
|
863
|
+
observations,
|
|
864
|
+
total: observations.length
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
// --- Audit ---
|
|
868
|
+
getEntityHistory(entityId) {
|
|
869
|
+
const rows = this.db.prepare(
|
|
870
|
+
"SELECT * FROM observations WHERE entity_id = ? ORDER BY observed_at ASC"
|
|
871
|
+
).all(entityId);
|
|
872
|
+
return rows.map((r) => this.rowToObservation(r));
|
|
873
|
+
}
|
|
874
|
+
getMemoryProvenance(observationId) {
|
|
875
|
+
const obs = this.getObservation(observationId);
|
|
876
|
+
if (!obs) return null;
|
|
877
|
+
const entity = this.getEntity(obs.entity_id);
|
|
878
|
+
if (!entity) return null;
|
|
879
|
+
return {
|
|
880
|
+
observation: obs,
|
|
881
|
+
entity,
|
|
882
|
+
receipt_id: obs.source_receipt_id,
|
|
883
|
+
chain: []
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
getMemoryStats(agentId, from, to) {
|
|
887
|
+
const entityConditions = [];
|
|
888
|
+
const obsConditions = [];
|
|
889
|
+
const params = [];
|
|
890
|
+
if (agentId) {
|
|
891
|
+
entityConditions.push("created_by_agent = ?");
|
|
892
|
+
obsConditions.push("source_agent_id = ?");
|
|
893
|
+
params.push(agentId);
|
|
894
|
+
}
|
|
895
|
+
const entityWhere = entityConditions.length > 0 ? `WHERE ${entityConditions.join(" AND ")}` : "";
|
|
896
|
+
const obsWhere = obsConditions.length > 0 ? `WHERE ${obsConditions.join(" AND ")}` : "";
|
|
897
|
+
const totalEntities = this.db.prepare(`SELECT COUNT(*) as cnt FROM entities ${entityWhere}`).get(...agentId ? [agentId] : []).cnt;
|
|
898
|
+
const totalObs = this.db.prepare(`SELECT COUNT(*) as cnt FROM observations ${obsWhere}`).get(...agentId ? [agentId] : []).cnt;
|
|
899
|
+
const totalRels = this.db.prepare("SELECT COUNT(*) as cnt FROM relationships").get().cnt;
|
|
900
|
+
const forgottenObs = this.db.prepare(`SELECT COUNT(*) as cnt FROM observations WHERE forgotten_at IS NOT NULL ${agentId ? "AND source_agent_id = ?" : ""}`).get(...agentId ? [agentId] : []).cnt;
|
|
901
|
+
const forgottenEntities = this.db.prepare(`SELECT COUNT(*) as cnt FROM entities WHERE forgotten_at IS NOT NULL ${agentId ? "AND created_by_agent = ?" : ""}`).get(...agentId ? [agentId] : []).cnt;
|
|
902
|
+
const typeRows = this.db.prepare("SELECT entity_type, COUNT(*) as cnt FROM entities GROUP BY entity_type").all();
|
|
903
|
+
const byType = {};
|
|
904
|
+
for (const r of typeRows) byType[r.entity_type] = r.cnt;
|
|
905
|
+
return {
|
|
906
|
+
total_entities: totalEntities,
|
|
907
|
+
total_observations: totalObs,
|
|
908
|
+
total_relationships: totalRels,
|
|
909
|
+
forgotten_observations: forgottenObs,
|
|
910
|
+
forgotten_entities: forgottenEntities,
|
|
911
|
+
by_entity_type: byType,
|
|
912
|
+
by_operation: {}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
// --- Duplicate detection ---
|
|
916
|
+
findPossibleDuplicates(entityId) {
|
|
917
|
+
const entity = this.getEntity(entityId);
|
|
918
|
+
if (!entity) return [];
|
|
919
|
+
const nameTokens = entity.name.toLowerCase().split(/\s+/).filter((t) => t.length >= 2);
|
|
920
|
+
if (nameTokens.length === 0) return [];
|
|
921
|
+
const conditions = nameTokens.map(() => "(LOWER(name) LIKE ? OR LOWER(aliases) LIKE ?)").join(" OR ");
|
|
922
|
+
const params = [];
|
|
923
|
+
for (const token of nameTokens) {
|
|
924
|
+
params.push(`%${token}%`, `%${token}%`);
|
|
925
|
+
}
|
|
926
|
+
const rows = this.db.prepare(`
|
|
927
|
+
SELECT * FROM entities
|
|
928
|
+
WHERE entity_type = ?
|
|
929
|
+
AND entity_id != ?
|
|
930
|
+
AND forgotten_at IS NULL
|
|
931
|
+
AND merged_into IS NULL
|
|
932
|
+
AND (${conditions})
|
|
933
|
+
`).all(entity.entity_type, entityId, ...params);
|
|
934
|
+
return rows.map((r) => this.rowToEntity(r));
|
|
935
|
+
}
|
|
936
|
+
// --- Context helpers ---
|
|
937
|
+
getTopEntities(limit, scope) {
|
|
938
|
+
const scopeFilter = scope ? "AND e.scope = ?" : "";
|
|
939
|
+
const params = scope ? [scope, limit] : [limit];
|
|
940
|
+
const rows = this.db.prepare(`
|
|
941
|
+
SELECT e.*, COUNT(o.observation_id) as obs_count, MAX(o.observed_at) as latest
|
|
942
|
+
FROM entities e
|
|
943
|
+
LEFT JOIN observations o ON o.entity_id = e.entity_id AND o.forgotten_at IS NULL
|
|
944
|
+
AND (o.expires_at IS NULL OR o.expires_at > datetime('now'))
|
|
945
|
+
WHERE e.forgotten_at IS NULL AND e.merged_into IS NULL ${scopeFilter}
|
|
946
|
+
GROUP BY e.entity_id
|
|
947
|
+
ORDER BY obs_count DESC
|
|
948
|
+
LIMIT ?
|
|
949
|
+
`).all(...params);
|
|
950
|
+
return rows.map((r) => ({
|
|
951
|
+
...this.rowToEntity(r),
|
|
952
|
+
observation_count: r.obs_count,
|
|
953
|
+
latest_observation: r.latest ?? ""
|
|
954
|
+
}));
|
|
955
|
+
}
|
|
956
|
+
getRecentObservations(limit, agentId) {
|
|
957
|
+
const agentFilter = agentId ? "AND source_agent_id = ?" : "";
|
|
958
|
+
const params = agentId ? [agentId, limit] : [limit];
|
|
959
|
+
const rows = this.db.prepare(`
|
|
960
|
+
SELECT * FROM observations
|
|
961
|
+
WHERE forgotten_at IS NULL
|
|
962
|
+
AND (expires_at IS NULL OR expires_at > datetime('now'))
|
|
963
|
+
${agentFilter}
|
|
964
|
+
ORDER BY observed_at DESC
|
|
965
|
+
LIMIT ?
|
|
966
|
+
`).all(...params);
|
|
967
|
+
return rows.map((r) => this.rowToObservation(r));
|
|
968
|
+
}
|
|
969
|
+
getActiveRelationships(limit) {
|
|
970
|
+
const rows = this.db.prepare(
|
|
971
|
+
"SELECT * FROM relationships WHERE forgotten_at IS NULL ORDER BY created_at DESC LIMIT ?"
|
|
972
|
+
).all(limit);
|
|
973
|
+
return rows.map((r) => this.rowToRelationship(r));
|
|
974
|
+
}
|
|
975
|
+
getPreferenceObservations(limit) {
|
|
976
|
+
const rows = this.db.prepare(`
|
|
977
|
+
SELECT o.* FROM observations o
|
|
978
|
+
JOIN entities e ON e.entity_id = o.entity_id
|
|
979
|
+
WHERE e.entity_type = 'preference'
|
|
980
|
+
AND o.forgotten_at IS NULL
|
|
981
|
+
AND (o.expires_at IS NULL OR o.expires_at > datetime('now'))
|
|
982
|
+
ORDER BY o.observed_at DESC
|
|
983
|
+
LIMIT ?
|
|
984
|
+
`).all(limit);
|
|
985
|
+
return rows.map((r) => this.rowToObservation(r));
|
|
986
|
+
}
|
|
987
|
+
getContextStats() {
|
|
988
|
+
const entities = this.db.prepare("SELECT COUNT(*) as cnt FROM entities WHERE forgotten_at IS NULL").get().cnt;
|
|
989
|
+
const observations = this.db.prepare("SELECT COUNT(*) as cnt FROM observations WHERE forgotten_at IS NULL AND (expires_at IS NULL OR expires_at > datetime('now'))").get().cnt;
|
|
990
|
+
const relationships = this.db.prepare("SELECT COUNT(*) as cnt FROM relationships WHERE forgotten_at IS NULL").get().cnt;
|
|
991
|
+
const agentRows = this.db.prepare("SELECT DISTINCT source_agent_id FROM observations WHERE forgotten_at IS NULL").all();
|
|
992
|
+
return {
|
|
993
|
+
total_entities: entities,
|
|
994
|
+
total_observations: observations,
|
|
995
|
+
total_relationships: relationships,
|
|
996
|
+
agents_contributing: agentRows.map((r) => r.source_agent_id)
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
// --- Cleanup ---
|
|
1000
|
+
cleanupExpiredObservations() {
|
|
1001
|
+
const result = this.db.prepare(`
|
|
1002
|
+
UPDATE observations SET forgotten_at = datetime('now'), forgotten_by = 'system:cleanup'
|
|
1003
|
+
WHERE expires_at IS NOT NULL AND expires_at <= datetime('now') AND forgotten_at IS NULL
|
|
1004
|
+
`).run();
|
|
1005
|
+
return result.changes;
|
|
1006
|
+
}
|
|
1007
|
+
// --- Row converters ---
|
|
1008
|
+
rowToEntity(row) {
|
|
1009
|
+
return {
|
|
1010
|
+
entity_id: row.entity_id,
|
|
1011
|
+
entity_type: row.entity_type,
|
|
1012
|
+
name: row.name,
|
|
1013
|
+
aliases: JSON.parse(row.aliases || "[]"),
|
|
1014
|
+
scope: row.scope,
|
|
1015
|
+
created_at: row.created_at,
|
|
1016
|
+
created_by_agent: row.created_by_agent,
|
|
1017
|
+
created_by_receipt: row.created_by_receipt,
|
|
1018
|
+
forgotten_at: row.forgotten_at || null,
|
|
1019
|
+
merged_into: row.merged_into || null,
|
|
1020
|
+
attributes: JSON.parse(row.attributes || "{}"),
|
|
1021
|
+
metadata: JSON.parse(row.metadata || "{}")
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
rowToObservation(row) {
|
|
1025
|
+
return {
|
|
1026
|
+
observation_id: row.observation_id,
|
|
1027
|
+
entity_id: row.entity_id,
|
|
1028
|
+
content: row.content,
|
|
1029
|
+
confidence: row.confidence,
|
|
1030
|
+
source_receipt_id: row.source_receipt_id,
|
|
1031
|
+
source_agent_id: row.source_agent_id,
|
|
1032
|
+
source_context: row.source_context || null,
|
|
1033
|
+
observed_at: row.observed_at,
|
|
1034
|
+
forgotten_at: row.forgotten_at || null,
|
|
1035
|
+
forgotten_by: row.forgotten_by || null,
|
|
1036
|
+
superseded_by: row.superseded_by || null,
|
|
1037
|
+
expires_at: row.expires_at || null,
|
|
1038
|
+
tags: JSON.parse(row.tags || "[]"),
|
|
1039
|
+
metadata: JSON.parse(row.metadata || "{}")
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
rowToRelationship(row) {
|
|
1043
|
+
return {
|
|
1044
|
+
relationship_id: row.relationship_id,
|
|
1045
|
+
from_entity_id: row.from_entity_id,
|
|
1046
|
+
to_entity_id: row.to_entity_id,
|
|
1047
|
+
relationship_type: row.relationship_type,
|
|
1048
|
+
strength: row.strength,
|
|
1049
|
+
source_receipt_id: row.source_receipt_id,
|
|
1050
|
+
created_at: row.created_at,
|
|
1051
|
+
forgotten_at: row.forgotten_at || null,
|
|
1052
|
+
metadata: JSON.parse(row.metadata || "{}")
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
477
1057
|
// src/engine/receipt-engine.ts
|
|
478
1058
|
import { nanoid } from "nanoid";
|
|
479
1059
|
import { ActionReceipt } from "@agent-receipts/schema";
|
|
@@ -1127,6 +1707,251 @@ var ReceiptEngine = class {
|
|
|
1127
1707
|
}
|
|
1128
1708
|
};
|
|
1129
1709
|
|
|
1710
|
+
// src/engine/memory-engine.ts
|
|
1711
|
+
import { nanoid as nanoid2 } from "nanoid";
|
|
1712
|
+
var MemoryEngine = class {
|
|
1713
|
+
constructor(receiptEngine, memoryStore) {
|
|
1714
|
+
this.receiptEngine = receiptEngine;
|
|
1715
|
+
this.memoryStore = memoryStore;
|
|
1716
|
+
}
|
|
1717
|
+
async observe(params) {
|
|
1718
|
+
const scope = params.scope ?? "agent";
|
|
1719
|
+
const confidence = params.confidence ?? "medium";
|
|
1720
|
+
let createdEntity = false;
|
|
1721
|
+
let entity = this.memoryStore.findEntityByName(params.entityName, params.entityType);
|
|
1722
|
+
const receipt = await this.receiptEngine.create({
|
|
1723
|
+
action: "memory.observe",
|
|
1724
|
+
receipt_type: "memory",
|
|
1725
|
+
input_hash: hashData({ entityName: params.entityName, content: params.content }),
|
|
1726
|
+
status: "completed",
|
|
1727
|
+
metadata: {
|
|
1728
|
+
memory: {
|
|
1729
|
+
memory_operation: "observe",
|
|
1730
|
+
entity_id: entity?.entity_id ?? null,
|
|
1731
|
+
observation_id: null,
|
|
1732
|
+
// Will be set below
|
|
1733
|
+
relationship_id: null,
|
|
1734
|
+
scope,
|
|
1735
|
+
query: null,
|
|
1736
|
+
results_count: null,
|
|
1737
|
+
confidence
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
if (!entity) {
|
|
1742
|
+
entity = this.memoryStore.createEntity({
|
|
1743
|
+
entity_id: `ent_${nanoid2(12)}`,
|
|
1744
|
+
entity_type: params.entityType,
|
|
1745
|
+
name: params.entityName,
|
|
1746
|
+
aliases: [],
|
|
1747
|
+
scope,
|
|
1748
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1749
|
+
created_by_agent: params.agentId,
|
|
1750
|
+
created_by_receipt: receipt.receipt_id,
|
|
1751
|
+
forgotten_at: null,
|
|
1752
|
+
merged_into: null,
|
|
1753
|
+
attributes: {},
|
|
1754
|
+
metadata: {}
|
|
1755
|
+
});
|
|
1756
|
+
createdEntity = true;
|
|
1757
|
+
}
|
|
1758
|
+
const observation = this.memoryStore.addObservation({
|
|
1759
|
+
observation_id: `obs_${nanoid2(12)}`,
|
|
1760
|
+
entity_id: entity.entity_id,
|
|
1761
|
+
content: params.content,
|
|
1762
|
+
confidence,
|
|
1763
|
+
source_receipt_id: receipt.receipt_id,
|
|
1764
|
+
source_agent_id: params.agentId,
|
|
1765
|
+
source_context: params.context ?? null,
|
|
1766
|
+
observed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1767
|
+
forgotten_at: null,
|
|
1768
|
+
forgotten_by: null,
|
|
1769
|
+
superseded_by: null,
|
|
1770
|
+
expires_at: params.ttlSeconds ? new Date(Date.now() + params.ttlSeconds * 1e3).toISOString() : null,
|
|
1771
|
+
tags: params.tags ?? [],
|
|
1772
|
+
metadata: {}
|
|
1773
|
+
});
|
|
1774
|
+
return { entity, observation, receipt, created_entity: createdEntity };
|
|
1775
|
+
}
|
|
1776
|
+
async recall(params) {
|
|
1777
|
+
const memoryQuery = {
|
|
1778
|
+
query: params.query,
|
|
1779
|
+
entity_type: params.entityType,
|
|
1780
|
+
entity_id: params.entityId,
|
|
1781
|
+
scope: params.scope,
|
|
1782
|
+
limit: params.limit ?? 20,
|
|
1783
|
+
include_forgotten: false,
|
|
1784
|
+
page: 1
|
|
1785
|
+
};
|
|
1786
|
+
const result = this.memoryStore.recall(memoryQuery);
|
|
1787
|
+
const receipt = await this.receiptEngine.create({
|
|
1788
|
+
action: "memory.recall",
|
|
1789
|
+
receipt_type: "memory",
|
|
1790
|
+
input_hash: hashData({ query: params.query, entityType: params.entityType, entityId: params.entityId }),
|
|
1791
|
+
output_hash: hashData({ entities: result.entities.length, observations: result.observations.length }),
|
|
1792
|
+
status: "completed",
|
|
1793
|
+
metadata: {
|
|
1794
|
+
memory: {
|
|
1795
|
+
memory_operation: "recall",
|
|
1796
|
+
entity_id: params.entityId ?? null,
|
|
1797
|
+
observation_id: null,
|
|
1798
|
+
relationship_id: null,
|
|
1799
|
+
scope: params.scope ?? "agent",
|
|
1800
|
+
query: params.query ?? null,
|
|
1801
|
+
results_count: result.total,
|
|
1802
|
+
confidence: null
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
return {
|
|
1807
|
+
entities: result.entities,
|
|
1808
|
+
observations: result.observations,
|
|
1809
|
+
receipt
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
async forget(params) {
|
|
1813
|
+
const operation = params.entityId ? "memory.forget_entity" : "memory.forget";
|
|
1814
|
+
if (params.entityId) {
|
|
1815
|
+
this.memoryStore.forgetEntity(params.entityId, params.agentId);
|
|
1816
|
+
} else if (params.observationId) {
|
|
1817
|
+
this.memoryStore.forgetObservation(params.observationId, params.agentId);
|
|
1818
|
+
} else {
|
|
1819
|
+
throw new Error("Either entityId or observationId must be provided");
|
|
1820
|
+
}
|
|
1821
|
+
const receipt = await this.receiptEngine.create({
|
|
1822
|
+
action: operation,
|
|
1823
|
+
receipt_type: "memory",
|
|
1824
|
+
input_hash: hashData({ entityId: params.entityId, observationId: params.observationId, reason: params.reason }),
|
|
1825
|
+
status: "completed",
|
|
1826
|
+
metadata: {
|
|
1827
|
+
memory: {
|
|
1828
|
+
memory_operation: params.entityId ? "forget_entity" : "forget",
|
|
1829
|
+
entity_id: params.entityId ?? null,
|
|
1830
|
+
observation_id: params.observationId ?? null,
|
|
1831
|
+
relationship_id: null,
|
|
1832
|
+
scope: "agent",
|
|
1833
|
+
query: null,
|
|
1834
|
+
results_count: null,
|
|
1835
|
+
confidence: null
|
|
1836
|
+
},
|
|
1837
|
+
reason: params.reason
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
return { receipt };
|
|
1841
|
+
}
|
|
1842
|
+
async relate(params) {
|
|
1843
|
+
const receipt = await this.receiptEngine.create({
|
|
1844
|
+
action: "memory.relate",
|
|
1845
|
+
receipt_type: "memory",
|
|
1846
|
+
input_hash: hashData({ from: params.fromEntityId, to: params.toEntityId, type: params.relationshipType }),
|
|
1847
|
+
status: "completed",
|
|
1848
|
+
metadata: {
|
|
1849
|
+
memory: {
|
|
1850
|
+
memory_operation: "observe",
|
|
1851
|
+
entity_id: params.fromEntityId,
|
|
1852
|
+
observation_id: null,
|
|
1853
|
+
relationship_id: null,
|
|
1854
|
+
scope: "agent",
|
|
1855
|
+
query: null,
|
|
1856
|
+
results_count: null,
|
|
1857
|
+
confidence: params.strength ?? "medium"
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
const relationship = this.memoryStore.addRelationship({
|
|
1862
|
+
relationship_id: `rel_${nanoid2(12)}`,
|
|
1863
|
+
from_entity_id: params.fromEntityId,
|
|
1864
|
+
to_entity_id: params.toEntityId,
|
|
1865
|
+
relationship_type: params.relationshipType,
|
|
1866
|
+
strength: params.strength ?? "medium",
|
|
1867
|
+
source_receipt_id: receipt.receipt_id,
|
|
1868
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1869
|
+
forgotten_at: null,
|
|
1870
|
+
metadata: params.context ? { context: params.context } : {}
|
|
1871
|
+
});
|
|
1872
|
+
return { relationship, receipt };
|
|
1873
|
+
}
|
|
1874
|
+
async merge(params) {
|
|
1875
|
+
const mergedEntity = this.memoryStore.mergeEntities(params.sourceEntityId, params.targetEntityId);
|
|
1876
|
+
const receipt = await this.receiptEngine.create({
|
|
1877
|
+
action: "memory.merge",
|
|
1878
|
+
receipt_type: "memory",
|
|
1879
|
+
input_hash: hashData({ source: params.sourceEntityId, target: params.targetEntityId }),
|
|
1880
|
+
output_hash: hashData(mergedEntity),
|
|
1881
|
+
status: "completed",
|
|
1882
|
+
metadata: {
|
|
1883
|
+
memory: {
|
|
1884
|
+
memory_operation: "merge",
|
|
1885
|
+
entity_id: params.targetEntityId,
|
|
1886
|
+
observation_id: null,
|
|
1887
|
+
relationship_id: null,
|
|
1888
|
+
scope: mergedEntity.scope,
|
|
1889
|
+
query: null,
|
|
1890
|
+
results_count: null,
|
|
1891
|
+
confidence: null
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
});
|
|
1895
|
+
return { mergedEntity, receipt };
|
|
1896
|
+
}
|
|
1897
|
+
provenance(observationId) {
|
|
1898
|
+
return this.memoryStore.getMemoryProvenance(observationId);
|
|
1899
|
+
}
|
|
1900
|
+
entityTimeline(entityId) {
|
|
1901
|
+
const observations = this.memoryStore.getEntityHistory(entityId);
|
|
1902
|
+
const relationships = this.memoryStore.getRelationships(entityId);
|
|
1903
|
+
const entries = [];
|
|
1904
|
+
for (const obs of observations) {
|
|
1905
|
+
entries.push({
|
|
1906
|
+
type: obs.forgotten_at ? "forget" : "observation",
|
|
1907
|
+
timestamp: obs.observed_at,
|
|
1908
|
+
data: obs
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
for (const rel of relationships) {
|
|
1912
|
+
entries.push({
|
|
1913
|
+
type: "relationship",
|
|
1914
|
+
timestamp: rel.created_at,
|
|
1915
|
+
data: rel
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
entries.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
1919
|
+
return entries;
|
|
1920
|
+
}
|
|
1921
|
+
memoryAudit(params) {
|
|
1922
|
+
return this.memoryStore.getMemoryStats(params.agentId, params.from, params.to);
|
|
1923
|
+
}
|
|
1924
|
+
async getContext(params) {
|
|
1925
|
+
const maxEntities = Math.min(params.maxEntities ?? 10, 50);
|
|
1926
|
+
const maxObservations = Math.min(params.maxObservations ?? 20, 100);
|
|
1927
|
+
const entities = this.memoryStore.getTopEntities(maxEntities, params.scope);
|
|
1928
|
+
const recent_observations = this.memoryStore.getRecentObservations(maxObservations, params.agentId);
|
|
1929
|
+
const relationships = this.memoryStore.getActiveRelationships(50);
|
|
1930
|
+
const preferences = this.memoryStore.getPreferenceObservations(20);
|
|
1931
|
+
const stats = this.memoryStore.getContextStats();
|
|
1932
|
+
const receipt = await this.receiptEngine.create({
|
|
1933
|
+
action: "memory.context",
|
|
1934
|
+
receipt_type: "memory",
|
|
1935
|
+
input_hash: hashData({ scope: params.scope, maxEntities, maxObservations }),
|
|
1936
|
+
output_hash: hashData({ entities: entities.length, observations: recent_observations.length }),
|
|
1937
|
+
status: "completed",
|
|
1938
|
+
metadata: {
|
|
1939
|
+
memory: {
|
|
1940
|
+
memory_operation: "recall",
|
|
1941
|
+
entity_id: null,
|
|
1942
|
+
observation_id: null,
|
|
1943
|
+
relationship_id: null,
|
|
1944
|
+
scope: params.scope ?? "agent",
|
|
1945
|
+
query: null,
|
|
1946
|
+
results_count: entities.length + recent_observations.length,
|
|
1947
|
+
confidence: null
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
return { entities, recent_observations, relationships, preferences, stats, receipt };
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
|
|
1130
1955
|
// src/engine/invoice-formatters.ts
|
|
1131
1956
|
function formatInvoiceJSON(invoice, includeReceipts = false) {
|
|
1132
1957
|
if (!includeReceipts) {
|
|
@@ -1722,6 +2547,8 @@ export {
|
|
|
1722
2547
|
ConfigManager,
|
|
1723
2548
|
ReceiptStore as JsonReceiptStore,
|
|
1724
2549
|
KeyManager,
|
|
2550
|
+
MemoryEngine,
|
|
2551
|
+
MemoryStore,
|
|
1725
2552
|
ReceiptEngine,
|
|
1726
2553
|
SqliteReceiptStore as ReceiptStore,
|
|
1727
2554
|
SqliteReceiptStore,
|