创建admin工作区
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts -H "X-API-Key: your-secret-root-key" -H "Content-Type: application/json" -d '{"account_id": "userB_account", "admin_user_id": "userB"}'

{"status":"ok","result":{"account_id":"userA_account","admin_user_id":"userA","isolate_user_scope_by_agent":false,"isolate_agent_scope_by_user":false,"user_key":"dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ"},"error":null,"telemetry":null,"profile":null}

{"status":"ok","result":{"account_id":"userB_account","admin_user_id":"userB","isolate_user_scope_by_agent":false,"isolate_agent_scope_by_user":false,"user_key":"dXNlckJfYWNjb3VudA.dXNlckI.YzZiNDZjMjJiZWMwNTM1OTBiOGEwMzAyOTFhZGMxZWQ4MTJhZDNhMmM5ZjJjZGYxMDI1YTkxZDVlMWY2M2M5MA"},"error":null,"telemetry":null,"profile":null}

创建用户
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts/admin/users -H "X-API-Key: your-secret-root-key" -H "Content-Type: application/json" -d '{"user_id": "userA", "role": "user"}'

userA
{"status":"ok","result":{"account_id":"admin","user_id":"userA","user_key":"3f7a4b4faae1e2d49583a0e45d9ba5b51f3d0f545d97c9b6c4f19171f717e8af"},"error":null,"telemetry":null}

userB
{"status":"ok","result":{"account_id":"admin","user_id":"userB","user_key":"3a017f01d1f9cddeec2b4832b4b3cb60b004ff27ec76505d72b24104412015c8"},"error":null,"telemetry":null}


创建session
userA
curl -X POST http://127.0.0.1:1933/api/v1/sessions \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -H "Content-Type: application/json" \
  -d '{"session_id":"sessionA1"}'

A1
{"status":"ok","result":{"session_id":"238a22c1-a32a-4a3a-a174-2112d476173b","user":{"account_id":"admin","user_id":"userA","agent_id":"default"}},"error":null,"telemetry":null}

A2
{"status":"ok","result":{"session_id":"d20cede5-30ba-4d98-81f9-d74ee83bb071","user":{"account_id":"admin","user_id":"userA","agent_id":"default"}},"error":null,"telemetry":null}

B1
{"status":"ok","result":{"session_id":"654248bf-c36f-4a61-9fe8-de8f207d5227","user":{"account_id":"admin","user_id":"userB","agent_id":"default"}},"error":null,"telemetry":null}

B2
{"status":"ok","result":{"session_id":"c567601c-28e8-4b3d-be10-c95c909b374e","user":{"account_id":"admin","user_id":"userB","agent_id":"default"}},"error":null,"telemetry":null}



对话session插入massage
userA A1
curl -X POST http://localhost:1933/api/v1/sessions/sessionA1/messages \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "user",
    "content": "我喜欢用 Python 写数据分析脚本。"
  }'

{"status":"ok","result":{"session_id":"sessionA1","message_count":1},"error":null,"telemetry":null}

curl -X POST http://localhost:1933/api/v1/sessions/sessionA1/messages \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "assistant",
    "content": "好的，我会记住你偏好 Python 数据分析。"
  }'
{"status":"ok","result":{"session_id":"sessionA1","message_count":2},"error":null,"telemetry":null}


userB B1
curl -X POST http://localhost:1933/api/v1/sessions/sessionB1/messages \
  -H "Authorization: Bearer 1e5f24acba77017e7506e6df9d668aebc0ddc91c4ed9af77c6d8da5e9d4ed6c7" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "user",
    "content": "我还想喝咖啡，咖啡有力气"
  }'
{"status":"ok","result":{"session_id":"sessionB1","message_count":1},"error":null,"telemetry":null}

curl -X POST http://localhost:1933/api/v1/sessions/sessionB1/messages \
  -H "Authorization: Bearer 1e5f24acba77017e7506e6df9d668aebc0ddc91c4ed9af77c6d8da5e9d4ed6c7" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "assistant",
    "content": "黑咖啡品味很浓，很有力气。"
  }'
{"status":"ok","result":{"session_id":"sessionB1","message_count":2},"error":null,"telemetry":null}



对话session插入memory
userA A1
curl -X POST http://localhost:1933/api/v1/sessions/sessionA1/commit \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" 

{"status":"ok","result":{"session_id":"sessionA1","status":"accepted","task_id":"1b93fcde-0944-42ad-a819-4241faf0048f","archive_uri":"viking://session/sessionA1/history/archive_001","archived":true,"trace_id":""}}

userB B1
curl -X POST http://localhost:1933/api/v1/sessions/sessionB1/commit \
  -H "Authorization: Bearer 1e5f24acba77017e7506e6df9d668aebc0ddc91c4ed9af77c6d8da5e9d4ed6c7" \
  -H "Content-Type: application/json" \
  -d '{"keep_recent_count":0}'
{"status":"ok","result":{"session_id":"sessionB1","status":"accepted","task_id":"cd98a696-ac6f-4f0c-8187-6e824f5ebcbc","archive_uri":"viking://session/userB/sessionB1/history/archive_001","archived":true}}

查询插入结果
userA A1
curl http://localhost:1933/api/v1/tasks/1b93fcde-0944-42ad-a819-4241faf0048f \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ"

{"status":"ok","result":{"task_id":"1b93fcde-0944-42ad-a819-4241faf0048f","task_type":"session_commit","status":"completed","created_at":1779855851.700087,"updated_at":1779855866.0683796,"resource_id":"sessionA1","result":{"session_id":"sessionA1","archive_uri":"viking://session/sessionA1/history/archive_001","memories_extracted":{"memory_write":1},"session_skills_extracted":0,"session_skill_uris":[],"active_count_updated":0,"token_usage":{"llm":{"prompt_tokens":7883,"completion_tokens":437,"total_tokens":8320},"embedding":{"total_tokens":49},"total":{"total_tokens":8369}}},"error":null,"created_at_iso":"2026-05-27T04:24:11.700087+00:00","updated_at_iso":"2026-05-27T04:24:26.068380+00:00"},"error":null,"telemetry":null,"profile":null}


userB B1
curl http://localhost:1933/api/v1/tasks/cd98a696-ac6f-4f0c-8187-6e824f5ebcbc \
  -H "Authorization: Bearer 3a017f01d1f9cddeec2b4832b4b3cb60b004ff27ec76505d72b24104412015c8"
{"status":"ok","result":{"task_id":"cd98a696-ac6f-4f0c-8187-6e824f5ebcbc","task_type":"session_commit","status":"running","created_at":1779418133.2990522,"updated_at":1779418133.2993288,"resource_id":"sessionB1","result":null,"error":null},"error":null,"telemetry":null}


向量搜索用户memory
curl -X POST http://localhost:1933/api/v1/search/find \
  -H "Content-Type: application/json" \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -d '{
    "query": "我之前说了什么",
    "limit": 3
  }' | jq .

{"status":"ok","result":{"memories":[{"context_type":"memory","uri":"viking://user/userA/memories/preferences/mem_d49a95a2-8491-40bb-b0d3-4cf4c16d3de8.md","level":2,"score":0.7411142547036441,"category":"","match_reason":"","relations":[],"abstract":"Python 数据分析：偏好使用 Python 编写数据分析脚本","overview":null},{"context_type":"memory","uri":"viking://user/userA/memories/preferences/.abstract.md","level":0,"score":0.6752108627461267,"category":"","match_reason":"","relations":[],"abstract":"This directory contains a single user preference document that captures a specific behavioral attribute regarding tool choice for data analysis. The document is a lightweight, non-technical profile note intended to record that the user prefers writing d...","overview":null},{"context_type":"memory","uri":"viking://user/userA/memories/.overview.md","level":1,"score":0.6262621398392979,"category":"","match_reason":"","relations":[],"abstract":"User's long-term memory storage. Contains memory types like preferences, entities, events, managed hierarchically by type.","overview":null}],"resources":[],"skills":[],"total":3}}


LLM搜索用户session memory

curl -s -X POST http://localhost:1933/api/v1/search/search \
  -H "Content-Type: application/json" \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -d '{
    "query": "我正在做什么",
    "limit": 10,
    "level": 2
  }' | jq .

{
  "status": "ok",
  "result": {
    "memories": [],
    "resources": [],
    "skills": [],
    "total": 0,
    "query_plan": {
      "reasoning": "1. Conversational task (user asking '我正在做什么' - 'What am I doing?'); 2. This is a simple conversational query about current state/activity; 3. The session context contains the user's previous interactions about Python preferences and EverOS API questions; 4. No specific context gaps need to be filled for this conversational task, but a memory query about the user's current activity context could help provide a more personalized response",
      "queries": [
        {
          "query": "User's current activity and task context",
          "context_type": "memory",
          "intent": "Understand what the user is currently working on to provide relevant context",
          "priority": 3
        }
      ]
    }
  }
}


curl -X GET "http://localhost:1933/api/v1/sessions/sessionA1" \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ"



组装 session 上下文
curl -X GET "http://localhost:1933/api/v1/sessions/{session_id}/context" \
  -H "X-API-Key: user key"

curl -X GET "http://localhost:1933/api/v1/sessions/sessionA1/context" \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" | jq .

获取指定 archive

curl -X GET "http://localhost:1933/api/v1/sessions/sessionA1/archives/archive_001" \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" | jq .

curl -sG "http://localhost:1933/api/v1/fs/ls" \
  --data-urlencode "uri=viking://user/alice1/memories/preferences/" \
  --data-urlencode "recursive=true" \
  -H "X-API-Key: 1d1a4d61838f67d808230b19ed1b6b4ce647f073ea33ee005ed3b9b24f35b978" | jq


上传临时文件
curl -s -X POST http://localhost:1933/api/v1/resources/temp_upload \
    -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
    -F "file=@/home/tom/memory-gateway/tests/大语言模型应用.pdf" \
  | jq .

{
  "status": "ok",
  "result": {
    "temp_file_id": "upload_89b818fa75114b35a5b2c55263dee8ff.pdf"
  }
}

上传图片
curl -X POST http://localhost:1933/api/v1/resources \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -H "Content-Type: application/json" \
  -d '{
    "temp_file_id": "upload_89b818fa75114b35a5b2c55263dee8ff.pdf",
    "to": "viking://resources/userA/files/大语言模型应用.pdf",
    "reason": "userA 上传的文件",
    "wait": true,
    "directly_upload_media": true
  }'


curl -X POST http://localhost:1933/api/v1/resources \
  -H "X-API-Key: dXNlckFfYWNjb3VudA.dXNlckE.OGU4NzczZmQ2ZDExNjNhMWI4OTg2MWZkZTk5OTcyODlhNmM2ZTZjNDNmOGJkMWRiZDk2M2QyNTdhYTZmMTFlYQ" \
  -H "Content-Type: application/json" \
  -d '{
    "temp_file_id": "upload_89b818fa75114b35a5b2c55263dee8ff.pdf",
    "to": "viking://resources/userA/files/大语言模型应用.pdf",
    "reason": "userA 上传的文件",
    "wait": true,
    "directly_upload_media": true
  }'


