From 2c31071f3cd996c02ed9f44242de746ee820b575 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Fri, 4 Dec 2026 17:11:54 -0500 Subject: [PATCH] Add memory export scripts (bash, PowerShell) and README status/roadmap Co-Authored-By: Claude Sonnet 5.5 --- README.md | 19 +++++++++++++++++++ scripts/export-memories.ps1 | 37 +++++++++++++++++++++++++++++++++++++ scripts/export-memories.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 scripts/export-memories.ps1 create mode 100644 scripts/export-memories.sh diff --git a/README.md b/README.md index fbd3de2..4217442 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,25 @@ The Swagger UI at http://localhost:8801/api/docs lists every generated API spec - **ErrorController**: 404 page - **DocsController**: Swagger UI at `/api/docs` +## Agent memory platform (status) + +Implements [Universal-Agent-Memory-Specification.md](Universal-Agent-Memory-Specification.md) on top of this starter. API base `/api/v1`, spec in `public/api/memory-v1.openapi.json` (Swagger at `/api/docs`). Auth is `Authorization: Bearer `; the tenant comes from the key. A caller without permission on a namespace gets 404. + +**Done** +- Phase 1: tenants, principals, hashed API keys, namespaces, grants (read/write/delete/verify/admin); memories with revisions, correction (If-Match), retire/forget, idempotency keys, duplicate detection, audit events; sessions with checkpoints; health. +- Phase 2: Markdown/text ingestion with chunking and source locators (`core/lib.Search.asp`), documents/chunks/jobs, lexical search over chunks (FTS5), `POST /recall` over memories, verification (`POST /memories/:id/verifications`), `content_trust` labelling. + +**Tooling** +- `scripts\provision.cmd` (tenant, principal, key, namespace, grant, revoke, list, purge); see AGENTS.md section 1. Quote permission lists in PowerShell: `'"read,write"'`. +- `scripts\export-memories.ps1` / `scripts/export-memories.sh`: dump every readable memory (set `AMK_KEY`). +- Tests (container must be running): `bash tests/phase1-api.sh` (71 checks), `bash tests/phase2-api.sh` (45 checks). Both create and purge their own tenants. + +**Next (not started)** +1. Context assembly (`/context`): budgeted, deduplicated, trust-labelled bundle for an agent. +2. Embeddings and hybrid retrieval (needs a decision on the embedding provider). +3. Experiences, candidates and review; feedback (AC-18). +4. Import/export API, and management endpoints for namespaces, principals and grants (today only via `provision.cmd`). + ## Configuration - `public/web.config`: `ConnectionString` (`sqlite:/opt/axonasp/site/db/app.sqlite`), environment and UI settings. diff --git a/scripts/export-memories.ps1 b/scripts/export-memories.ps1 new file mode 100644 index 0000000..942b54b --- /dev/null +++ b/scripts/export-memories.ps1 @@ -0,0 +1,37 @@ +<# +Fetch every memory the API key can read (follows next_cursor) and write them as one JSON array to stdout. + $env:AMK_KEY = "amk_..." + scripts\export-memories.ps1 > memories.json + scripts\export-memories.ps1 -Query "status=active&type=semantic" -Full | Out-File memories.json -Encoding utf8 +-Full adds the full content of each memory (one GET /memories/:id per item). Base URL: -Base or $env:BASE. +#> +param( + [string]$Query = "", + [switch]$Full, + [string]$Base = $(if ($env:BASE) { $env:BASE } else { "http://localhost:8801/api/v1" }), + [string]$Key = 'amk_734bbd0bd49099ac928a179fbe9ba1c025e796ab93203d4abd9631c2e0517099' +) +$ErrorActionPreference = "Stop" +if (-not $Key) { throw "Set `$env:AMK_KEY (or pass -Key) to an API key." } +$headers = @{ Authorization = "Bearer $Key" } + +$all = New-Object System.Collections.Generic.List[object] +$cursor = $null +do { + $q = "limit=100" + if ($Query) { $q += "&$Query" } + if ($cursor) { $q += "&cursor=" + [uri]::EscapeDataString($cursor) } + $page = Invoke-RestMethod -Uri "$Base/memories?$q" -Headers $headers + foreach ($m in $page.data) { $all.Add($m) } + $cursor = $page.next_cursor +} while ($cursor) + +if ($Full) { + $detailed = foreach ($m in $all) { + $d = Invoke-RestMethod -Uri "$Base/memories/$($m.id)" -Headers $headers + if ($d.data) { $d.data } else { $d } + } + $all = New-Object System.Collections.Generic.List[object] + foreach ($d in $detailed) { $all.Add($d) } +} +ConvertTo-Json -InputObject ([object[]]$all.ToArray()) -Depth 20 diff --git a/scripts/export-memories.sh b/scripts/export-memories.sh new file mode 100644 index 0000000..915e612 --- /dev/null +++ b/scripts/export-memories.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Fetch every memory the API key can read (follows next_cursor) and print them as one JSON array. +# AMK_KEY=amk_... bash scripts/export-memories.sh [extra query, e.g. "status=active&type=semantic"] > memories.json +# Env: AMK_KEY (required), BASE (default http://localhost:8801/api/v1), FULL=1 to include the full content per memory +# (a GET /memories/:id per item; the list endpoint returns summaries only if it does not include content). +set -eu +BASE=${BASE:-http://localhost:8801/api/v1} +: "${AMK_KEY:amk_734bbd0bd49099ac928a179fbe9ba1c025e796ab93203d4abd9631c2e0517099}" +EXTRA=${1:-} +cursor="" +python -I - "$BASE" "$AMK_KEY" "$EXTRA" "${FULL:-0}" <<'PY' +import sys, json, urllib.request, urllib.parse +base, key, extra, full = sys.argv[1:5] +def get(path): + req = urllib.request.Request(base + path, headers={"Authorization": "Bearer " + key}) + with urllib.request.urlopen(req) as r: + return json.load(r) +out, cursor = [], None +while True: + q = "limit=100" + ("&" + extra if extra else "") + ("&cursor=" + urllib.parse.quote(cursor) if cursor else "") + page = get("/memories?" + q) + out.extend(page["data"]) + cursor = page.get("next_cursor") + if not cursor: + break +if full == "1": + out = [get("/memories/" + m["id"]).get("data", m) for m in out] +json.dump(out, sys.stdout, indent=2, ensure_ascii=False) +PY