Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

3824 řádky
102KB

  1. {
  2. "openapi": "3.0.3",
  3. "info": {
  4. "title": "Agent Memory API",
  5. "version": "1.0.0-phase3",
  6. "description": "Universal AI Agent Memory platform, phases 1-3: memories with revisions and verification, sessions with checkpoints, Markdown/text document ingestion with chunk locators, lexical search and recall, health. Authenticate with `Authorization: Bearer <api key>`; the tenant is derived from the key. Anything the caller cannot see is reported as 404. Phase 3: POST /context assembles a budgeted task briefing. Retrieval is hybrid (lexical + embeddings via a local Ollama model and a Qdrant index) and degrades to lexical with a warning. Relevance scores are ranking signals: negated bm25 when lexical, reciprocal-rank-fusion values when hybrid. Learning loop: experiences (POST /sessions/{id}/events), candidates proposed with POST /learn and reviewed by another principal (POST /candidates/{id}/review), evidence (GET /memories/{id}/sources) and feedback on retrieval results (POST /feedback, using the query_id of recall/search/context)."
  7. },
  8. "servers": [
  9. {
  10. "url": "/api/v1"
  11. }
  12. ],
  13. "components": {
  14. "securitySchemes": {
  15. "bearerAuth": {
  16. "type": "http",
  17. "scheme": "bearer"
  18. }
  19. },
  20. "schemas": {
  21. "Error": {
  22. "type": "object",
  23. "properties": {
  24. "error": {
  25. "type": "object",
  26. "properties": {
  27. "code": {
  28. "type": "string"
  29. },
  30. "message": {
  31. "type": "string"
  32. },
  33. "details": {
  34. "type": "array",
  35. "items": {
  36. "type": "string"
  37. }
  38. },
  39. "request_id": {
  40. "type": "string"
  41. }
  42. }
  43. }
  44. }
  45. },
  46. "RememberRequest": {
  47. "type": "object",
  48. "required": [
  49. "namespace_id",
  50. "type",
  51. "title",
  52. "content"
  53. ],
  54. "properties": {
  55. "namespace_id": {
  56. "type": "string",
  57. "format": "uuid"
  58. },
  59. "type": {
  60. "type": "string",
  61. "enum": [
  62. "working",
  63. "episodic",
  64. "semantic",
  65. "procedural",
  66. "preference",
  67. "decision",
  68. "constraint",
  69. "lesson",
  70. "hypothesis",
  71. "goal",
  72. "solution"
  73. ]
  74. },
  75. "title": {
  76. "type": "string",
  77. "maxLength": 200
  78. },
  79. "content": {
  80. "type": "string",
  81. "maxLength": 100000
  82. },
  83. "summary": {
  84. "type": "string",
  85. "maxLength": 2000,
  86. "nullable": true
  87. },
  88. "tags": {
  89. "type": "array",
  90. "items": {
  91. "type": "string",
  92. "maxLength": 64
  93. },
  94. "maxItems": 32
  95. },
  96. "attributes": {
  97. "type": "object",
  98. "description": "Free-form JSON object, max 16 KB"
  99. },
  100. "confidence": {
  101. "type": "number",
  102. "minimum": 0,
  103. "maximum": 1
  104. },
  105. "importance": {
  106. "type": "number",
  107. "minimum": 0,
  108. "maximum": 1
  109. }
  110. }
  111. },
  112. "RememberResponse": {
  113. "type": "object",
  114. "properties": {
  115. "id": {
  116. "type": "string",
  117. "format": "uuid"
  118. },
  119. "revision": {
  120. "type": "integer"
  121. },
  122. "status": {
  123. "type": "string"
  124. },
  125. "verification_status": {
  126. "type": "string"
  127. },
  128. "indexing_status": {
  129. "type": "string",
  130. "example": "not_indexed"
  131. },
  132. "duplicate": {
  133. "type": "boolean",
  134. "description": "true when an identical active memory already existed (HTTP 200)"
  135. }
  136. }
  137. },
  138. "Memory": {
  139. "type": "object",
  140. "properties": {
  141. "id": {
  142. "type": "string"
  143. },
  144. "namespace_id": {
  145. "type": "string"
  146. },
  147. "type": {
  148. "type": "string"
  149. },
  150. "status": {
  151. "type": "string",
  152. "enum": [
  153. "active",
  154. "retired",
  155. "superseded"
  156. ]
  157. },
  158. "current_revision": {
  159. "type": "integer"
  160. },
  161. "revision": {
  162. "type": "integer"
  163. },
  164. "verification_status": {
  165. "type": "string",
  166. "enum": [
  167. "unverified",
  168. "verified",
  169. "disputed",
  170. "rejected"
  171. ]
  172. },
  173. "title": {
  174. "type": "string"
  175. },
  176. "summary": {
  177. "type": "string",
  178. "nullable": true
  179. },
  180. "content": {
  181. "type": "string"
  182. },
  183. "attributes": {
  184. "type": "object",
  185. "nullable": true
  186. },
  187. "tags": {
  188. "type": "array",
  189. "items": {
  190. "type": "string"
  191. }
  192. },
  193. "confidence": {
  194. "type": "number",
  195. "nullable": true
  196. },
  197. "importance": {
  198. "type": "number",
  199. "nullable": true
  200. },
  201. "change_reason": {
  202. "type": "string",
  203. "nullable": true
  204. },
  205. "created_by": {
  206. "type": "string"
  207. },
  208. "created_at": {
  209. "type": "string"
  210. },
  211. "updated_at": {
  212. "type": "string"
  213. }
  214. }
  215. },
  216. "IngestRequest": {
  217. "type": "object",
  218. "required": [
  219. "namespace_id",
  220. "title",
  221. "content"
  222. ],
  223. "properties": {
  224. "namespace_id": {
  225. "type": "string",
  226. "format": "uuid"
  227. },
  228. "title": {
  229. "type": "string",
  230. "maxLength": 200
  231. },
  232. "content": {
  233. "type": "string",
  234. "maxLength": 262144
  235. },
  236. "format": {
  237. "type": "string",
  238. "enum": [
  239. "markdown",
  240. "text"
  241. ],
  242. "default": "markdown"
  243. },
  244. "source_uri": {
  245. "type": "string",
  246. "maxLength": 500,
  247. "description": "Identifier only; never fetched. The same source_uri in a namespace is one document."
  248. }
  249. }
  250. },
  251. "IngestResponse": {
  252. "type": "object",
  253. "properties": {
  254. "job": {
  255. "type": "object",
  256. "properties": {
  257. "id": {
  258. "type": "string"
  259. },
  260. "type": {
  261. "type": "string"
  262. },
  263. "state": {
  264. "type": "string"
  265. }
  266. }
  267. },
  268. "document_id": {
  269. "type": "string"
  270. },
  271. "revision": {
  272. "type": "integer"
  273. },
  274. "chunk_count": {
  275. "type": "integer"
  276. },
  277. "unchanged": {
  278. "type": "boolean",
  279. "description": "true when identical text was already the current revision (no new chunks)"
  280. },
  281. "indexing_status": {
  282. "type": "string",
  283. "example": "lexical_indexed"
  284. }
  285. }
  286. },
  287. "SearchRequest": {
  288. "type": "object",
  289. "required": [
  290. "query"
  291. ],
  292. "properties": {
  293. "query": {
  294. "type": "string",
  295. "maxLength": 1000
  296. },
  297. "namespace_ids": {
  298. "type": "array",
  299. "items": {
  300. "type": "string",
  301. "format": "uuid"
  302. }
  303. },
  304. "max_results": {
  305. "type": "integer",
  306. "minimum": 1,
  307. "maximum": 50
  308. },
  309. "detail_level": {
  310. "type": "string",
  311. "enum": [
  312. "full",
  313. "snippet"
  314. ]
  315. }
  316. }
  317. },
  318. "RecallRequest": {
  319. "type": "object",
  320. "required": [
  321. "query"
  322. ],
  323. "properties": {
  324. "query": {
  325. "type": "string",
  326. "maxLength": 1000
  327. },
  328. "namespace_ids": {
  329. "type": "array",
  330. "items": {
  331. "type": "string",
  332. "format": "uuid"
  333. }
  334. },
  335. "types": {
  336. "type": "array",
  337. "items": {
  338. "type": "string"
  339. }
  340. },
  341. "tags": {
  342. "type": "array",
  343. "items": {
  344. "type": "string"
  345. }
  346. },
  347. "max_results": {
  348. "type": "integer"
  349. },
  350. "detail_level": {
  351. "type": "string",
  352. "enum": [
  353. "full",
  354. "summary"
  355. ]
  356. },
  357. "verification_filter": {
  358. "type": "string",
  359. "enum": [
  360. "verified_only",
  361. "include_unverified"
  362. ],
  363. "default": "verified_only"
  364. }
  365. }
  366. },
  367. "VerifyRequest": {
  368. "type": "object",
  369. "required": [
  370. "result",
  371. "method",
  372. "revision"
  373. ],
  374. "properties": {
  375. "result": {
  376. "type": "string",
  377. "enum": [
  378. "verified",
  379. "disputed",
  380. "rejected"
  381. ]
  382. },
  383. "method": {
  384. "type": "string",
  385. "maxLength": 200
  386. },
  387. "notes": {
  388. "type": "string",
  389. "maxLength": 2000
  390. },
  391. "revision": {
  392. "type": "integer",
  393. "description": "Must be the current revision"
  394. }
  395. }
  396. },
  397. "SaveStateRequest": {
  398. "type": "object",
  399. "required": [
  400. "state"
  401. ],
  402. "properties": {
  403. "state": {
  404. "type": "object",
  405. "description": "Structured working state, max 64 KB"
  406. },
  407. "expected_revision": {
  408. "type": "integer"
  409. }
  410. }
  411. },
  412. "ContextRequest": {
  413. "type": "object",
  414. "required": [
  415. "task"
  416. ],
  417. "properties": {
  418. "task": {
  419. "type": "string",
  420. "maxLength": 2000,
  421. "description": "What the agent is about to do; used as the lexical query for decisions, lessons, knowledge and references."
  422. },
  423. "namespace_ids": {
  424. "type": "array",
  425. "items": {
  426. "type": "string"
  427. },
  428. "description": "Restrict to these namespaces (intersected with what the caller can read)."
  429. },
  430. "session_id": {
  431. "type": "string",
  432. "description": "Include the session's latest checkpoint as working_state. 404 when the session is not visible."
  433. },
  434. "include": {
  435. "type": "array",
  436. "items": {
  437. "type": "string",
  438. "enum": [
  439. "constraints",
  440. "preferences",
  441. "decisions",
  442. "lessons",
  443. "knowledge",
  444. "references",
  445. "working_state"
  446. ]
  447. },
  448. "description": "Sections to assemble (default all). Constraints and conflicts are always included."
  449. },
  450. "verification_filter": {
  451. "type": "string",
  452. "enum": [
  453. "verified_only",
  454. "include_unverified"
  455. ],
  456. "default": "verified_only"
  457. },
  458. "detail_level": {
  459. "type": "string",
  460. "enum": [
  461. "full",
  462. "summary"
  463. ],
  464. "default": "full",
  465. "description": "summary returns the stored summary (or first 240 characters); constraints are always full."
  466. },
  467. "max_context_tokens": {
  468. "type": "integer",
  469. "minimum": 100,
  470. "maximum": 32000,
  471. "default": 4000
  472. },
  473. "max_items": {
  474. "type": "integer",
  475. "minimum": 1,
  476. "maximum": 50,
  477. "default": 10,
  478. "description": "Per-section cap for conflicts, decisions, lessons, knowledge and unverified (preferences: 50)."
  479. },
  480. "max_references": {
  481. "type": "integer",
  482. "minimum": 0,
  483. "maximum": 20,
  484. "default": 5
  485. },
  486. "format": {
  487. "type": "string",
  488. "enum": [
  489. "structured"
  490. ],
  491. "default": "structured"
  492. }
  493. },
  494. "example": {
  495. "task": "Implement a customer repository",
  496. "session_id": "<session id>",
  497. "include": [
  498. "constraints",
  499. "decisions",
  500. "preferences",
  501. "lessons",
  502. "references",
  503. "working_state"
  504. ],
  505. "max_context_tokens": 4000
  506. }
  507. },
  508. "ContextResponse": {
  509. "type": "object",
  510. "description": "Sections in budget priority order: constraints (required), working_state, preferences, conflicts, decisions, lessons, knowledge, references, unverified. Memory items carry id, revision, type, namespace_id, title, content|summary, verification_status, content_trust (verified_memory|unverified_memory|disputed_memory), authority (policy for verified constraints), tags, confidence, importance, relevance_score (lexical matches), valid_until, provenance {created_by, updated_at} and token_estimate. References carry chunk/document ids, locator, content and content_trust untrusted_reference.",
  511. "properties": {
  512. "context_id": {
  513. "type": "string"
  514. },
  515. "task": {
  516. "type": "string"
  517. },
  518. "strategy": {
  519. "type": "string",
  520. "enum": [
  521. "hybrid",
  522. "lexical"
  523. ],
  524. "description": "hybrid when semantic retrieval ran for every section; lexical (with a warning) when it is not configured or unavailable"
  525. },
  526. "budget": {
  527. "type": "object",
  528. "properties": {
  529. "max_context_tokens": {
  530. "type": "integer"
  531. },
  532. "used_tokens": {
  533. "type": "integer"
  534. },
  535. "counting_method": {
  536. "type": "string",
  537. "example": "estimate_chars_div_4"
  538. },
  539. "complete": {
  540. "type": "boolean",
  541. "description": "False when not every applicable constraint/preference could be considered; do not treat the briefing as complete."
  542. },
  543. "truncated": {
  544. "type": "boolean",
  545. "description": "True when items were left out to fit the budget."
  546. }
  547. }
  548. },
  549. "omitted": {
  550. "type": "object",
  551. "properties": {
  552. "over_budget": {
  553. "type": "integer"
  554. },
  555. "over_limit": {
  556. "type": "integer"
  557. },
  558. "duplicates": {
  559. "type": "integer"
  560. },
  561. "unverified_excluded": {
  562. "type": "integer"
  563. }
  564. }
  565. },
  566. "constraints": {
  567. "type": "array",
  568. "items": {
  569. "type": "object"
  570. }
  571. },
  572. "working_state": {
  573. "type": "object",
  574. "nullable": true
  575. },
  576. "preferences": {
  577. "type": "array",
  578. "items": {
  579. "type": "object"
  580. }
  581. },
  582. "conflicts": {
  583. "type": "array",
  584. "items": {
  585. "type": "object"
  586. }
  587. },
  588. "decisions": {
  589. "type": "array",
  590. "items": {
  591. "type": "object"
  592. }
  593. },
  594. "lessons": {
  595. "type": "array",
  596. "items": {
  597. "type": "object"
  598. }
  599. },
  600. "knowledge": {
  601. "type": "array",
  602. "items": {
  603. "type": "object"
  604. }
  605. },
  606. "references": {
  607. "type": "array",
  608. "items": {
  609. "type": "object"
  610. }
  611. },
  612. "unverified": {
  613. "type": "array",
  614. "items": {
  615. "type": "object"
  616. },
  617. "description": "Only with verification_filter include_unverified."
  618. },
  619. "warnings": {
  620. "type": "array",
  621. "items": {
  622. "type": "string"
  623. }
  624. },
  625. "query_id": {
  626. "type": "string",
  627. "description": "Pass to POST /feedback to rate an included memory or reference"
  628. }
  629. }
  630. },
  631. "EvidenceInput": {
  632. "type": "object",
  633. "required": [
  634. "kind",
  635. "id"
  636. ],
  637. "properties": {
  638. "kind": {
  639. "type": "string",
  640. "enum": [
  641. "experience",
  642. "chunk",
  643. "memory",
  644. "document"
  645. ]
  646. },
  647. "id": {
  648. "type": "string",
  649. "format": "uuid"
  650. },
  651. "role": {
  652. "type": "string",
  653. "enum": [
  654. "supports",
  655. "contradicts",
  656. "context"
  657. ],
  658. "default": "supports"
  659. },
  660. "excerpt": {
  661. "type": "string",
  662. "maxLength": 2000
  663. }
  664. }
  665. },
  666. "ExperienceRequest": {
  667. "type": "object",
  668. "required": [
  669. "task",
  670. "outcome"
  671. ],
  672. "properties": {
  673. "task": {
  674. "type": "string",
  675. "maxLength": 2000
  676. },
  677. "outcome": {
  678. "type": "string",
  679. "enum": [
  680. "success",
  681. "failure",
  682. "partial",
  683. "unknown"
  684. ]
  685. },
  686. "problem": {
  687. "type": "string",
  688. "maxLength": 4000
  689. },
  690. "action": {
  691. "type": "string",
  692. "maxLength": 4000
  693. },
  694. "result": {
  695. "type": "string",
  696. "maxLength": 4000
  697. },
  698. "environment": {
  699. "type": "object",
  700. "description": "Free-form JSON object, max 16 KB"
  701. }
  702. }
  703. },
  704. "Experience": {
  705. "type": "object",
  706. "properties": {
  707. "id": {
  708. "type": "string"
  709. },
  710. "task": {
  711. "type": "string"
  712. },
  713. "problem": {
  714. "type": "string"
  715. },
  716. "action": {
  717. "type": "string"
  718. },
  719. "result": {
  720. "type": "string"
  721. },
  722. "outcome": {
  723. "type": "string"
  724. },
  725. "recorded_by": {
  726. "type": "string"
  727. },
  728. "created_at": {
  729. "type": "string"
  730. },
  731. "environment": {
  732. "type": "object",
  733. "nullable": true
  734. }
  735. }
  736. },
  737. "LearnRequest": {
  738. "type": "object",
  739. "required": [
  740. "namespace_id",
  741. "type",
  742. "title",
  743. "content"
  744. ],
  745. "properties": {
  746. "namespace_id": {
  747. "type": "string",
  748. "format": "uuid"
  749. },
  750. "type": {
  751. "type": "string"
  752. },
  753. "title": {
  754. "type": "string",
  755. "maxLength": 200
  756. },
  757. "content": {
  758. "type": "string",
  759. "maxLength": 100000
  760. },
  761. "summary": {
  762. "type": "string",
  763. "maxLength": 2000
  764. },
  765. "tags": {
  766. "type": "array",
  767. "items": {
  768. "type": "string"
  769. },
  770. "maxItems": 32
  771. },
  772. "confidence": {
  773. "type": "number",
  774. "minimum": 0,
  775. "maximum": 1
  776. },
  777. "target_memory_id": {
  778. "type": "string",
  779. "format": "uuid",
  780. "description": "Propose a new revision of this memory (same namespace and type)"
  781. },
  782. "base_revision": {
  783. "type": "integer",
  784. "description": "Required with target_memory_id: the revision the proposal is based on"
  785. },
  786. "evidence": {
  787. "type": "array",
  788. "maxItems": 20,
  789. "items": {
  790. "$ref": "#/components/schemas/EvidenceInput"
  791. }
  792. }
  793. }
  794. },
  795. "Candidate": {
  796. "type": "object",
  797. "properties": {
  798. "id": {
  799. "type": "string"
  800. },
  801. "namespace_id": {
  802. "type": "string"
  803. },
  804. "type": {
  805. "type": "string"
  806. },
  807. "title": {
  808. "type": "string"
  809. },
  810. "summary": {
  811. "type": "string",
  812. "nullable": true
  813. },
  814. "content": {
  815. "type": "string",
  816. "description": "Detail only"
  817. },
  818. "tags": {
  819. "type": "array",
  820. "items": {
  821. "type": "string"
  822. }
  823. },
  824. "confidence": {
  825. "type": "number",
  826. "nullable": true
  827. },
  828. "target_memory_id": {
  829. "type": "string",
  830. "nullable": true
  831. },
  832. "base_revision": {
  833. "type": "integer",
  834. "nullable": true
  835. },
  836. "state": {
  837. "type": "string",
  838. "enum": [
  839. "proposed",
  840. "accepted",
  841. "rejected"
  842. ]
  843. },
  844. "author": {
  845. "type": "string"
  846. },
  847. "reviewer": {
  848. "type": "string",
  849. "nullable": true
  850. },
  851. "review_notes": {
  852. "type": "string",
  853. "nullable": true
  854. },
  855. "resulting_memory_id": {
  856. "type": "string",
  857. "nullable": true
  858. },
  859. "resulting_revision": {
  860. "type": "integer",
  861. "nullable": true
  862. },
  863. "created_at": {
  864. "type": "string"
  865. },
  866. "reviewed_at": {
  867. "type": "string",
  868. "nullable": true
  869. },
  870. "content_trust": {
  871. "type": "string",
  872. "enum": [
  873. "proposed_knowledge"
  874. ]
  875. },
  876. "evidence": {
  877. "type": "array",
  878. "items": {
  879. "$ref": "#/components/schemas/EvidenceItem"
  880. },
  881. "description": "Detail only"
  882. }
  883. }
  884. },
  885. "EvidenceItem": {
  886. "type": "object",
  887. "properties": {
  888. "kind": {
  889. "type": "string"
  890. },
  891. "id": {
  892. "type": "string",
  893. "description": "Omitted when available is false"
  894. },
  895. "revision": {
  896. "type": "integer",
  897. "nullable": true,
  898. "description": "Target revision pinned when the link was made"
  899. },
  900. "available": {
  901. "type": "boolean",
  902. "description": "False when the target is gone or the caller cannot read it"
  903. },
  904. "role": {
  905. "type": "string"
  906. },
  907. "excerpt": {
  908. "type": "string",
  909. "nullable": true
  910. },
  911. "content_trust": {
  912. "type": "string",
  913. "enum": [
  914. "evidence",
  915. "untrusted_reference"
  916. ]
  917. }
  918. }
  919. },
  920. "ReviewRequest": {
  921. "type": "object",
  922. "required": [
  923. "decision"
  924. ],
  925. "properties": {
  926. "decision": {
  927. "type": "string",
  928. "enum": [
  929. "accept",
  930. "reject"
  931. ]
  932. },
  933. "notes": {
  934. "type": "string",
  935. "maxLength": 2000
  936. },
  937. "verify": {
  938. "type": "boolean",
  939. "default": false,
  940. "description": "Accept as verified (records a verification by the reviewer)"
  941. }
  942. }
  943. },
  944. "Sources": {
  945. "type": "object",
  946. "properties": {
  947. "memory_id": {
  948. "type": "string"
  949. },
  950. "revision": {
  951. "type": "integer"
  952. },
  953. "current_revision": {
  954. "type": "integer"
  955. },
  956. "from_candidate": {
  957. "type": "string",
  958. "nullable": true
  959. },
  960. "evidence": {
  961. "type": "array",
  962. "items": {
  963. "$ref": "#/components/schemas/EvidenceItem"
  964. }
  965. },
  966. "verifications": {
  967. "type": "array",
  968. "items": {
  969. "type": "object",
  970. "properties": {
  971. "method": {
  972. "type": "string"
  973. },
  974. "result": {
  975. "type": "string"
  976. },
  977. "notes": {
  978. "type": "string"
  979. },
  980. "reviewer": {
  981. "type": "string"
  982. },
  983. "created_at": {
  984. "type": "string"
  985. }
  986. }
  987. }
  988. }
  989. }
  990. },
  991. "FeedbackRequest": {
  992. "type": "object",
  993. "required": [
  994. "query_id",
  995. "result_id",
  996. "usefulness"
  997. ],
  998. "properties": {
  999. "query_id": {
  1000. "type": "string",
  1001. "description": "query_id returned by recall, search or context"
  1002. },
  1003. "result_id": {
  1004. "type": "string",
  1005. "format": "uuid",
  1006. "description": "Memory id or chunk id from that response"
  1007. },
  1008. "usefulness": {
  1009. "type": "string",
  1010. "enum": [
  1011. "useful",
  1012. "not_useful",
  1013. "incorrect",
  1014. "harmful"
  1015. ]
  1016. },
  1017. "comment": {
  1018. "type": "string",
  1019. "maxLength": 2000
  1020. }
  1021. }
  1022. },
  1023. "Feedback": {
  1024. "type": "object",
  1025. "properties": {
  1026. "id": {
  1027. "type": "string"
  1028. },
  1029. "query_id": {
  1030. "type": "string"
  1031. },
  1032. "target_kind": {
  1033. "type": "string",
  1034. "enum": [
  1035. "memory",
  1036. "chunk"
  1037. ]
  1038. },
  1039. "target_id": {
  1040. "type": "string"
  1041. },
  1042. "target_revision": {
  1043. "type": "integer"
  1044. },
  1045. "usefulness": {
  1046. "type": "string"
  1047. }
  1048. }
  1049. },
  1050. "ExportRequest": {
  1051. "type": "object",
  1052. "properties": {
  1053. "namespace_ids": {
  1054. "type": "array",
  1055. "items": {
  1056. "type": "string",
  1057. "format": "uuid"
  1058. },
  1059. "description": "Limit the export to these namespaces (unreadable ones are skipped silently). Default: all readable namespaces."
  1060. }
  1061. }
  1062. },
  1063. "Export": {
  1064. "type": "object",
  1065. "required": [
  1066. "format",
  1067. "schema_version",
  1068. "data",
  1069. "integrity"
  1070. ],
  1071. "properties": {
  1072. "format": {
  1073. "type": "string",
  1074. "enum": [
  1075. "agent-memory-export"
  1076. ]
  1077. },
  1078. "schema_version": {
  1079. "type": "integer",
  1080. "enum": [
  1081. 1
  1082. ]
  1083. },
  1084. "exported_at": {
  1085. "type": "string"
  1086. },
  1087. "data": {
  1088. "type": "object",
  1089. "description": "namespaces [{path}], memories [{id, namespace, type, lifecycle_status, valid_from, valid_until, created_by, created_at, updated_at, current_revision, revisions[], verifications[]}], documents [{id, namespace, source_uri, format, title, current_revision, created_by, created_at, updated_at, revisions[{..., chunks[]}]}], evidence_links [{id, owner_kind, owner_id, owner_revision, target_kind, target_id, target_revision, role, excerpt, created_by, created_at}]. Not in version 1: sessions, experiences, candidates, feedback, retrieval telemetry, audit events.",
  1090. "properties": {
  1091. "namespaces": {
  1092. "type": "array",
  1093. "items": {
  1094. "type": "object"
  1095. }
  1096. },
  1097. "memories": {
  1098. "type": "array",
  1099. "items": {
  1100. "type": "object"
  1101. }
  1102. },
  1103. "documents": {
  1104. "type": "array",
  1105. "items": {
  1106. "type": "object"
  1107. }
  1108. },
  1109. "evidence_links": {
  1110. "type": "array",
  1111. "items": {
  1112. "type": "object"
  1113. }
  1114. }
  1115. }
  1116. },
  1117. "counts": {
  1118. "type": "object",
  1119. "additionalProperties": {
  1120. "type": "integer"
  1121. },
  1122. "description": "namespaces, memories, memory_revisions, verifications, documents, document_revisions, chunks, evidence_links, evidence_links_omitted"
  1123. },
  1124. "integrity": {
  1125. "type": "object",
  1126. "properties": {
  1127. "algorithm": {
  1128. "type": "string",
  1129. "enum": [
  1130. "sha256"
  1131. ]
  1132. },
  1133. "digest": {
  1134. "type": "string",
  1135. "description": "Hex SHA-256 of the exact UTF-8 text of the data value as it appears in the document; any reformatting breaks it."
  1136. }
  1137. }
  1138. }
  1139. }
  1140. },
  1141. "ImportResult": {
  1142. "type": "object",
  1143. "properties": {
  1144. "imported": {
  1145. "type": "object",
  1146. "additionalProperties": {
  1147. "type": "integer"
  1148. },
  1149. "description": "namespaces, memories, memory_revisions, verifications, documents, document_revisions, chunks, evidence_links"
  1150. },
  1151. "indexing": {
  1152. "type": "object",
  1153. "properties": {
  1154. "lexical": {
  1155. "type": "string"
  1156. },
  1157. "semantic": {
  1158. "type": "string"
  1159. }
  1160. }
  1161. }
  1162. }
  1163. }
  1164. }
  1165. },
  1166. "paths": {
  1167. "/remember": {
  1168. "post": {
  1169. "summary": "Create a memory",
  1170. "security": [
  1171. {
  1172. "bearerAuth": []
  1173. }
  1174. ],
  1175. "parameters": [
  1176. {
  1177. "name": "Idempotency-Key",
  1178. "in": "header",
  1179. "required": false,
  1180. "description": "Replays the stored response for an identical body; a different body with the same key is 409.",
  1181. "schema": {
  1182. "type": "string",
  1183. "maxLength": 200
  1184. }
  1185. }
  1186. ],
  1187. "requestBody": {
  1188. "required": true,
  1189. "content": {
  1190. "application/json": {
  1191. "schema": {
  1192. "$ref": "#/components/schemas/RememberRequest"
  1193. }
  1194. }
  1195. }
  1196. },
  1197. "responses": {
  1198. "201": {
  1199. "description": "Created",
  1200. "content": {
  1201. "application/json": {
  1202. "schema": {
  1203. "$ref": "#/components/schemas/RememberResponse"
  1204. }
  1205. }
  1206. }
  1207. },
  1208. "200": {
  1209. "description": "Exact duplicate (or idempotent replay of a 200)",
  1210. "content": {
  1211. "application/json": {
  1212. "schema": {
  1213. "$ref": "#/components/schemas/RememberResponse"
  1214. }
  1215. }
  1216. }
  1217. },
  1218. "400": {
  1219. "description": "Invalid JSON / body",
  1220. "content": {
  1221. "application/json": {
  1222. "schema": {
  1223. "$ref": "#/components/schemas/Error"
  1224. }
  1225. }
  1226. }
  1227. },
  1228. "409": {
  1229. "description": "Idempotency-Key reused with a different body",
  1230. "content": {
  1231. "application/json": {
  1232. "schema": {
  1233. "$ref": "#/components/schemas/Error"
  1234. }
  1235. }
  1236. }
  1237. },
  1238. "422": {
  1239. "description": "Validation failed",
  1240. "content": {
  1241. "application/json": {
  1242. "schema": {
  1243. "$ref": "#/components/schemas/Error"
  1244. }
  1245. }
  1246. }
  1247. },
  1248. "401": {
  1249. "description": "Missing, invalid, revoked or expired API key",
  1250. "content": {
  1251. "application/json": {
  1252. "schema": {
  1253. "$ref": "#/components/schemas/Error"
  1254. }
  1255. }
  1256. }
  1257. },
  1258. "404": {
  1259. "description": "Not found or not visible to the caller",
  1260. "content": {
  1261. "application/json": {
  1262. "schema": {
  1263. "$ref": "#/components/schemas/Error"
  1264. }
  1265. }
  1266. }
  1267. },
  1268. "500": {
  1269. "description": "Internal error",
  1270. "content": {
  1271. "application/json": {
  1272. "schema": {
  1273. "$ref": "#/components/schemas/Error"
  1274. }
  1275. }
  1276. }
  1277. }
  1278. }
  1279. }
  1280. },
  1281. "/memories": {
  1282. "get": {
  1283. "summary": "List memories (newest first)",
  1284. "security": [
  1285. {
  1286. "bearerAuth": []
  1287. }
  1288. ],
  1289. "parameters": [
  1290. {
  1291. "name": "namespace_id",
  1292. "in": "query",
  1293. "schema": {
  1294. "type": "string",
  1295. "format": "uuid"
  1296. }
  1297. },
  1298. {
  1299. "name": "type",
  1300. "in": "query",
  1301. "schema": {
  1302. "type": "string"
  1303. }
  1304. },
  1305. {
  1306. "name": "status",
  1307. "in": "query",
  1308. "schema": {
  1309. "type": "string",
  1310. "enum": [
  1311. "active",
  1312. "retired",
  1313. "superseded",
  1314. "all"
  1315. ],
  1316. "default": "active"
  1317. }
  1318. },
  1319. {
  1320. "name": "verification_status",
  1321. "in": "query",
  1322. "schema": {
  1323. "type": "string",
  1324. "enum": [
  1325. "unverified",
  1326. "verified",
  1327. "disputed",
  1328. "rejected"
  1329. ]
  1330. }
  1331. },
  1332. {
  1333. "name": "limit",
  1334. "in": "query",
  1335. "schema": {
  1336. "type": "integer",
  1337. "minimum": 1,
  1338. "maximum": 100,
  1339. "default": 20
  1340. }
  1341. },
  1342. {
  1343. "name": "cursor",
  1344. "in": "query",
  1345. "description": "next_cursor from the previous page",
  1346. "schema": {
  1347. "type": "string"
  1348. }
  1349. }
  1350. ],
  1351. "responses": {
  1352. "200": {
  1353. "description": "Page of memories",
  1354. "content": {
  1355. "application/json": {
  1356. "schema": {
  1357. "type": "object",
  1358. "properties": {
  1359. "data": {
  1360. "type": "array",
  1361. "items": {
  1362. "$ref": "#/components/schemas/Memory"
  1363. }
  1364. },
  1365. "next_cursor": {
  1366. "type": "string",
  1367. "nullable": true
  1368. }
  1369. }
  1370. }
  1371. }
  1372. }
  1373. },
  1374. "400": {
  1375. "description": "Invalid cursor",
  1376. "content": {
  1377. "application/json": {
  1378. "schema": {
  1379. "$ref": "#/components/schemas/Error"
  1380. }
  1381. }
  1382. }
  1383. },
  1384. "422": {
  1385. "description": "Invalid filter",
  1386. "content": {
  1387. "application/json": {
  1388. "schema": {
  1389. "$ref": "#/components/schemas/Error"
  1390. }
  1391. }
  1392. }
  1393. },
  1394. "401": {
  1395. "description": "Missing, invalid, revoked or expired API key",
  1396. "content": {
  1397. "application/json": {
  1398. "schema": {
  1399. "$ref": "#/components/schemas/Error"
  1400. }
  1401. }
  1402. }
  1403. },
  1404. "404": {
  1405. "description": "Not found or not visible to the caller",
  1406. "content": {
  1407. "application/json": {
  1408. "schema": {
  1409. "$ref": "#/components/schemas/Error"
  1410. }
  1411. }
  1412. }
  1413. },
  1414. "500": {
  1415. "description": "Internal error",
  1416. "content": {
  1417. "application/json": {
  1418. "schema": {
  1419. "$ref": "#/components/schemas/Error"
  1420. }
  1421. }
  1422. }
  1423. }
  1424. }
  1425. }
  1426. },
  1427. "/memories/{id}": {
  1428. "get": {
  1429. "summary": "Get a memory (optionally an older revision)",
  1430. "security": [
  1431. {
  1432. "bearerAuth": []
  1433. }
  1434. ],
  1435. "parameters": [
  1436. {
  1437. "name": "id",
  1438. "in": "path",
  1439. "required": true,
  1440. "schema": {
  1441. "type": "string",
  1442. "format": "uuid"
  1443. }
  1444. },
  1445. {
  1446. "name": "revision",
  1447. "in": "query",
  1448. "schema": {
  1449. "type": "integer"
  1450. }
  1451. }
  1452. ],
  1453. "responses": {
  1454. "200": {
  1455. "description": "The memory",
  1456. "content": {
  1457. "application/json": {
  1458. "schema": {
  1459. "type": "object",
  1460. "properties": {
  1461. "data": {
  1462. "$ref": "#/components/schemas/Memory"
  1463. }
  1464. }
  1465. }
  1466. }
  1467. }
  1468. },
  1469. "401": {
  1470. "description": "Missing, invalid, revoked or expired API key",
  1471. "content": {
  1472. "application/json": {
  1473. "schema": {
  1474. "$ref": "#/components/schemas/Error"
  1475. }
  1476. }
  1477. }
  1478. },
  1479. "404": {
  1480. "description": "Not found or not visible to the caller",
  1481. "content": {
  1482. "application/json": {
  1483. "schema": {
  1484. "$ref": "#/components/schemas/Error"
  1485. }
  1486. }
  1487. }
  1488. },
  1489. "500": {
  1490. "description": "Internal error",
  1491. "content": {
  1492. "application/json": {
  1493. "schema": {
  1494. "$ref": "#/components/schemas/Error"
  1495. }
  1496. }
  1497. }
  1498. }
  1499. }
  1500. },
  1501. "patch": {
  1502. "summary": "Correct a memory: creates the next revision, unverified",
  1503. "security": [
  1504. {
  1505. "bearerAuth": []
  1506. }
  1507. ],
  1508. "parameters": [
  1509. {
  1510. "name": "id",
  1511. "in": "path",
  1512. "required": true,
  1513. "schema": {
  1514. "type": "string",
  1515. "format": "uuid"
  1516. }
  1517. },
  1518. {
  1519. "name": "If-Match",
  1520. "in": "header",
  1521. "required": false,
  1522. "description": "Current revision number (quoted ETag form accepted). Required unless expected_revision is in the body.",
  1523. "schema": {
  1524. "type": "string"
  1525. }
  1526. }
  1527. ],
  1528. "requestBody": {
  1529. "required": true,
  1530. "content": {
  1531. "application/json": {
  1532. "schema": {
  1533. "type": "object",
  1534. "properties": {
  1535. "title": {
  1536. "type": "string"
  1537. },
  1538. "summary": {
  1539. "type": "string"
  1540. },
  1541. "content": {
  1542. "type": "string"
  1543. },
  1544. "tags": {
  1545. "type": "array",
  1546. "items": {
  1547. "type": "string"
  1548. }
  1549. },
  1550. "attributes": {
  1551. "type": "object"
  1552. },
  1553. "confidence": {
  1554. "type": "number"
  1555. },
  1556. "importance": {
  1557. "type": "number"
  1558. },
  1559. "change_reason": {
  1560. "type": "string"
  1561. },
  1562. "expected_revision": {
  1563. "type": "integer"
  1564. }
  1565. }
  1566. }
  1567. }
  1568. }
  1569. },
  1570. "responses": {
  1571. "200": {
  1572. "description": "New revision",
  1573. "content": {
  1574. "application/json": {
  1575. "schema": {
  1576. "$ref": "#/components/schemas/RememberResponse"
  1577. }
  1578. }
  1579. }
  1580. },
  1581. "400": {
  1582. "description": "Bad body / revision",
  1583. "content": {
  1584. "application/json": {
  1585. "schema": {
  1586. "$ref": "#/components/schemas/Error"
  1587. }
  1588. }
  1589. }
  1590. },
  1591. "409": {
  1592. "description": "Memory is not active",
  1593. "content": {
  1594. "application/json": {
  1595. "schema": {
  1596. "$ref": "#/components/schemas/Error"
  1597. }
  1598. }
  1599. }
  1600. },
  1601. "412": {
  1602. "description": "Stale revision (ETag header carries the current one)",
  1603. "content": {
  1604. "application/json": {
  1605. "schema": {
  1606. "$ref": "#/components/schemas/Error"
  1607. }
  1608. }
  1609. }
  1610. },
  1611. "422": {
  1612. "description": "Validation failed",
  1613. "content": {
  1614. "application/json": {
  1615. "schema": {
  1616. "$ref": "#/components/schemas/Error"
  1617. }
  1618. }
  1619. }
  1620. },
  1621. "428": {
  1622. "description": "If-Match missing",
  1623. "content": {
  1624. "application/json": {
  1625. "schema": {
  1626. "$ref": "#/components/schemas/Error"
  1627. }
  1628. }
  1629. }
  1630. },
  1631. "401": {
  1632. "description": "Missing, invalid, revoked or expired API key",
  1633. "content": {
  1634. "application/json": {
  1635. "schema": {
  1636. "$ref": "#/components/schemas/Error"
  1637. }
  1638. }
  1639. }
  1640. },
  1641. "404": {
  1642. "description": "Not found or not visible to the caller",
  1643. "content": {
  1644. "application/json": {
  1645. "schema": {
  1646. "$ref": "#/components/schemas/Error"
  1647. }
  1648. }
  1649. }
  1650. },
  1651. "500": {
  1652. "description": "Internal error",
  1653. "content": {
  1654. "application/json": {
  1655. "schema": {
  1656. "$ref": "#/components/schemas/Error"
  1657. }
  1658. }
  1659. }
  1660. }
  1661. }
  1662. },
  1663. "delete": {
  1664. "summary": "Forget: permanently delete the memory and its revisions (needs delete permission)",
  1665. "security": [
  1666. {
  1667. "bearerAuth": []
  1668. }
  1669. ],
  1670. "parameters": [
  1671. {
  1672. "name": "id",
  1673. "in": "path",
  1674. "required": true,
  1675. "schema": {
  1676. "type": "string",
  1677. "format": "uuid"
  1678. }
  1679. }
  1680. ],
  1681. "responses": {
  1682. "200": {
  1683. "description": "Deleted"
  1684. },
  1685. "401": {
  1686. "description": "Missing, invalid, revoked or expired API key",
  1687. "content": {
  1688. "application/json": {
  1689. "schema": {
  1690. "$ref": "#/components/schemas/Error"
  1691. }
  1692. }
  1693. }
  1694. },
  1695. "404": {
  1696. "description": "Not found or not visible to the caller",
  1697. "content": {
  1698. "application/json": {
  1699. "schema": {
  1700. "$ref": "#/components/schemas/Error"
  1701. }
  1702. }
  1703. }
  1704. },
  1705. "500": {
  1706. "description": "Internal error",
  1707. "content": {
  1708. "application/json": {
  1709. "schema": {
  1710. "$ref": "#/components/schemas/Error"
  1711. }
  1712. }
  1713. }
  1714. }
  1715. }
  1716. }
  1717. },
  1718. "/memories/{id}/retire": {
  1719. "post": {
  1720. "summary": "Retire: exclude from ordinary listing",
  1721. "security": [
  1722. {
  1723. "bearerAuth": []
  1724. }
  1725. ],
  1726. "parameters": [
  1727. {
  1728. "name": "id",
  1729. "in": "path",
  1730. "required": true,
  1731. "schema": {
  1732. "type": "string",
  1733. "format": "uuid"
  1734. }
  1735. }
  1736. ],
  1737. "responses": {
  1738. "200": {
  1739. "description": "Retired"
  1740. },
  1741. "401": {
  1742. "description": "Missing, invalid, revoked or expired API key",
  1743. "content": {
  1744. "application/json": {
  1745. "schema": {
  1746. "$ref": "#/components/schemas/Error"
  1747. }
  1748. }
  1749. }
  1750. },
  1751. "404": {
  1752. "description": "Not found or not visible to the caller",
  1753. "content": {
  1754. "application/json": {
  1755. "schema": {
  1756. "$ref": "#/components/schemas/Error"
  1757. }
  1758. }
  1759. }
  1760. },
  1761. "500": {
  1762. "description": "Internal error",
  1763. "content": {
  1764. "application/json": {
  1765. "schema": {
  1766. "$ref": "#/components/schemas/Error"
  1767. }
  1768. }
  1769. }
  1770. }
  1771. }
  1772. }
  1773. },
  1774. "/memories/{id}/versions": {
  1775. "get": {
  1776. "summary": "Revision history, newest first",
  1777. "security": [
  1778. {
  1779. "bearerAuth": []
  1780. }
  1781. ],
  1782. "parameters": [
  1783. {
  1784. "name": "id",
  1785. "in": "path",
  1786. "required": true,
  1787. "schema": {
  1788. "type": "string",
  1789. "format": "uuid"
  1790. }
  1791. }
  1792. ],
  1793. "responses": {
  1794. "200": {
  1795. "description": "Revisions"
  1796. },
  1797. "401": {
  1798. "description": "Missing, invalid, revoked or expired API key",
  1799. "content": {
  1800. "application/json": {
  1801. "schema": {
  1802. "$ref": "#/components/schemas/Error"
  1803. }
  1804. }
  1805. }
  1806. },
  1807. "404": {
  1808. "description": "Not found or not visible to the caller",
  1809. "content": {
  1810. "application/json": {
  1811. "schema": {
  1812. "$ref": "#/components/schemas/Error"
  1813. }
  1814. }
  1815. }
  1816. },
  1817. "500": {
  1818. "description": "Internal error",
  1819. "content": {
  1820. "application/json": {
  1821. "schema": {
  1822. "$ref": "#/components/schemas/Error"
  1823. }
  1824. }
  1825. }
  1826. }
  1827. }
  1828. }
  1829. },
  1830. "/sessions": {
  1831. "post": {
  1832. "summary": "Start a session",
  1833. "security": [
  1834. {
  1835. "bearerAuth": []
  1836. }
  1837. ],
  1838. "parameters": [
  1839. {
  1840. "name": "Idempotency-Key",
  1841. "in": "header",
  1842. "required": false,
  1843. "description": "Replays the stored response for an identical body; a different body with the same key is 409.",
  1844. "schema": {
  1845. "type": "string",
  1846. "maxLength": 200
  1847. }
  1848. }
  1849. ],
  1850. "requestBody": {
  1851. "required": true,
  1852. "content": {
  1853. "application/json": {
  1854. "schema": {
  1855. "type": "object",
  1856. "required": [
  1857. "namespace_id",
  1858. "objective"
  1859. ],
  1860. "properties": {
  1861. "namespace_id": {
  1862. "type": "string",
  1863. "format": "uuid"
  1864. },
  1865. "objective": {
  1866. "type": "string",
  1867. "maxLength": 2000
  1868. }
  1869. }
  1870. }
  1871. }
  1872. }
  1873. },
  1874. "responses": {
  1875. "201": {
  1876. "description": "Started"
  1877. },
  1878. "422": {
  1879. "description": "Validation failed",
  1880. "content": {
  1881. "application/json": {
  1882. "schema": {
  1883. "$ref": "#/components/schemas/Error"
  1884. }
  1885. }
  1886. }
  1887. },
  1888. "409": {
  1889. "description": "Idempotency conflict",
  1890. "content": {
  1891. "application/json": {
  1892. "schema": {
  1893. "$ref": "#/components/schemas/Error"
  1894. }
  1895. }
  1896. }
  1897. },
  1898. "401": {
  1899. "description": "Missing, invalid, revoked or expired API key",
  1900. "content": {
  1901. "application/json": {
  1902. "schema": {
  1903. "$ref": "#/components/schemas/Error"
  1904. }
  1905. }
  1906. }
  1907. },
  1908. "404": {
  1909. "description": "Not found or not visible to the caller",
  1910. "content": {
  1911. "application/json": {
  1912. "schema": {
  1913. "$ref": "#/components/schemas/Error"
  1914. }
  1915. }
  1916. }
  1917. },
  1918. "500": {
  1919. "description": "Internal error",
  1920. "content": {
  1921. "application/json": {
  1922. "schema": {
  1923. "$ref": "#/components/schemas/Error"
  1924. }
  1925. }
  1926. }
  1927. }
  1928. }
  1929. }
  1930. },
  1931. "/sessions/{id}/state": {
  1932. "get": {
  1933. "summary": "Restore the latest checkpoint (revision 0 / state null when none)",
  1934. "security": [
  1935. {
  1936. "bearerAuth": []
  1937. }
  1938. ],
  1939. "parameters": [
  1940. {
  1941. "name": "id",
  1942. "in": "path",
  1943. "required": true,
  1944. "schema": {
  1945. "type": "string",
  1946. "format": "uuid"
  1947. }
  1948. }
  1949. ],
  1950. "responses": {
  1951. "200": {
  1952. "description": "Checkpoint; ETag = revision"
  1953. },
  1954. "401": {
  1955. "description": "Missing, invalid, revoked or expired API key",
  1956. "content": {
  1957. "application/json": {
  1958. "schema": {
  1959. "$ref": "#/components/schemas/Error"
  1960. }
  1961. }
  1962. }
  1963. },
  1964. "404": {
  1965. "description": "Not found or not visible to the caller",
  1966. "content": {
  1967. "application/json": {
  1968. "schema": {
  1969. "$ref": "#/components/schemas/Error"
  1970. }
  1971. }
  1972. }
  1973. },
  1974. "500": {
  1975. "description": "Internal error",
  1976. "content": {
  1977. "application/json": {
  1978. "schema": {
  1979. "$ref": "#/components/schemas/Error"
  1980. }
  1981. }
  1982. }
  1983. }
  1984. }
  1985. },
  1986. "put": {
  1987. "summary": "Save a checkpoint (If-Match = current checkpoint revision, 0 for the first)",
  1988. "security": [
  1989. {
  1990. "bearerAuth": []
  1991. }
  1992. ],
  1993. "parameters": [
  1994. {
  1995. "name": "id",
  1996. "in": "path",
  1997. "required": true,
  1998. "schema": {
  1999. "type": "string",
  2000. "format": "uuid"
  2001. }
  2002. },
  2003. {
  2004. "name": "If-Match",
  2005. "in": "header",
  2006. "required": false,
  2007. "description": "Current revision number (quoted ETag form accepted). Required unless expected_revision is in the body.",
  2008. "schema": {
  2009. "type": "string"
  2010. }
  2011. }
  2012. ],
  2013. "requestBody": {
  2014. "required": true,
  2015. "content": {
  2016. "application/json": {
  2017. "schema": {
  2018. "$ref": "#/components/schemas/SaveStateRequest"
  2019. }
  2020. }
  2021. }
  2022. },
  2023. "responses": {
  2024. "200": {
  2025. "description": "Saved; ETag = new revision"
  2026. },
  2027. "409": {
  2028. "description": "Session closed",
  2029. "content": {
  2030. "application/json": {
  2031. "schema": {
  2032. "$ref": "#/components/schemas/Error"
  2033. }
  2034. }
  2035. }
  2036. },
  2037. "412": {
  2038. "description": "Stale revision",
  2039. "content": {
  2040. "application/json": {
  2041. "schema": {
  2042. "$ref": "#/components/schemas/Error"
  2043. }
  2044. }
  2045. }
  2046. },
  2047. "422": {
  2048. "description": "Validation failed",
  2049. "content": {
  2050. "application/json": {
  2051. "schema": {
  2052. "$ref": "#/components/schemas/Error"
  2053. }
  2054. }
  2055. }
  2056. },
  2057. "428": {
  2058. "description": "If-Match missing",
  2059. "content": {
  2060. "application/json": {
  2061. "schema": {
  2062. "$ref": "#/components/schemas/Error"
  2063. }
  2064. }
  2065. }
  2066. },
  2067. "401": {
  2068. "description": "Missing, invalid, revoked or expired API key",
  2069. "content": {
  2070. "application/json": {
  2071. "schema": {
  2072. "$ref": "#/components/schemas/Error"
  2073. }
  2074. }
  2075. }
  2076. },
  2077. "404": {
  2078. "description": "Not found or not visible to the caller",
  2079. "content": {
  2080. "application/json": {
  2081. "schema": {
  2082. "$ref": "#/components/schemas/Error"
  2083. }
  2084. }
  2085. }
  2086. },
  2087. "500": {
  2088. "description": "Internal error",
  2089. "content": {
  2090. "application/json": {
  2091. "schema": {
  2092. "$ref": "#/components/schemas/Error"
  2093. }
  2094. }
  2095. }
  2096. }
  2097. }
  2098. }
  2099. },
  2100. "/sessions/{id}/complete": {
  2101. "post": {
  2102. "summary": "Complete a session",
  2103. "security": [
  2104. {
  2105. "bearerAuth": []
  2106. }
  2107. ],
  2108. "parameters": [
  2109. {
  2110. "name": "id",
  2111. "in": "path",
  2112. "required": true,
  2113. "schema": {
  2114. "type": "string",
  2115. "format": "uuid"
  2116. }
  2117. }
  2118. ],
  2119. "requestBody": {
  2120. "required": false,
  2121. "content": {
  2122. "application/json": {
  2123. "schema": {
  2124. "type": "object",
  2125. "properties": {
  2126. "outcome": {
  2127. "type": "string",
  2128. "maxLength": 4000
  2129. }
  2130. }
  2131. }
  2132. }
  2133. }
  2134. },
  2135. "responses": {
  2136. "200": {
  2137. "description": "Completed"
  2138. },
  2139. "409": {
  2140. "description": "Already closed",
  2141. "content": {
  2142. "application/json": {
  2143. "schema": {
  2144. "$ref": "#/components/schemas/Error"
  2145. }
  2146. }
  2147. }
  2148. },
  2149. "401": {
  2150. "description": "Missing, invalid, revoked or expired API key",
  2151. "content": {
  2152. "application/json": {
  2153. "schema": {
  2154. "$ref": "#/components/schemas/Error"
  2155. }
  2156. }
  2157. }
  2158. },
  2159. "404": {
  2160. "description": "Not found or not visible to the caller",
  2161. "content": {
  2162. "application/json": {
  2163. "schema": {
  2164. "$ref": "#/components/schemas/Error"
  2165. }
  2166. }
  2167. }
  2168. },
  2169. "500": {
  2170. "description": "Internal error",
  2171. "content": {
  2172. "application/json": {
  2173. "schema": {
  2174. "$ref": "#/components/schemas/Error"
  2175. }
  2176. }
  2177. }
  2178. }
  2179. }
  2180. }
  2181. },
  2182. "/memories/{id}/verifications": {
  2183. "post": {
  2184. "summary": "Record a verification of the current revision (needs the verify permission)",
  2185. "security": [
  2186. {
  2187. "bearerAuth": []
  2188. }
  2189. ],
  2190. "parameters": [
  2191. {
  2192. "name": "id",
  2193. "in": "path",
  2194. "required": true,
  2195. "schema": {
  2196. "type": "string",
  2197. "format": "uuid"
  2198. }
  2199. }
  2200. ],
  2201. "requestBody": {
  2202. "required": true,
  2203. "content": {
  2204. "application/json": {
  2205. "schema": {
  2206. "$ref": "#/components/schemas/VerifyRequest"
  2207. }
  2208. }
  2209. }
  2210. },
  2211. "responses": {
  2212. "200": {
  2213. "description": "Recorded; returns the new verification_status"
  2214. },
  2215. "409": {
  2216. "description": "Not the current revision",
  2217. "content": {
  2218. "application/json": {
  2219. "schema": {
  2220. "$ref": "#/components/schemas/Error"
  2221. }
  2222. }
  2223. }
  2224. },
  2225. "422": {
  2226. "description": "Validation failed",
  2227. "content": {
  2228. "application/json": {
  2229. "schema": {
  2230. "$ref": "#/components/schemas/Error"
  2231. }
  2232. }
  2233. }
  2234. },
  2235. "401": {
  2236. "description": "Missing, invalid, revoked or expired API key",
  2237. "content": {
  2238. "application/json": {
  2239. "schema": {
  2240. "$ref": "#/components/schemas/Error"
  2241. }
  2242. }
  2243. }
  2244. },
  2245. "404": {
  2246. "description": "Not found or not visible to the caller",
  2247. "content": {
  2248. "application/json": {
  2249. "schema": {
  2250. "$ref": "#/components/schemas/Error"
  2251. }
  2252. }
  2253. }
  2254. },
  2255. "500": {
  2256. "description": "Internal error",
  2257. "content": {
  2258. "application/json": {
  2259. "schema": {
  2260. "$ref": "#/components/schemas/Error"
  2261. }
  2262. }
  2263. }
  2264. }
  2265. }
  2266. }
  2267. },
  2268. "/recall": {
  2269. "post": {
  2270. "summary": "Hybrid recall over active memories (FTS5/bm25 fused with vector similarity by reciprocal rank fusion; lexical only, with a warning, when the embedding provider is off or down). Unverified memories are hidden unless verification_filter=include_unverified",
  2271. "security": [
  2272. {
  2273. "bearerAuth": []
  2274. }
  2275. ],
  2276. "requestBody": {
  2277. "required": true,
  2278. "content": {
  2279. "application/json": {
  2280. "schema": {
  2281. "$ref": "#/components/schemas/RecallRequest"
  2282. }
  2283. }
  2284. }
  2285. },
  2286. "responses": {
  2287. "200": {
  2288. "description": "Ranked results with warnings"
  2289. },
  2290. "422": {
  2291. "description": "Validation failed",
  2292. "content": {
  2293. "application/json": {
  2294. "schema": {
  2295. "$ref": "#/components/schemas/Error"
  2296. }
  2297. }
  2298. }
  2299. },
  2300. "401": {
  2301. "description": "Missing, invalid, revoked or expired API key",
  2302. "content": {
  2303. "application/json": {
  2304. "schema": {
  2305. "$ref": "#/components/schemas/Error"
  2306. }
  2307. }
  2308. }
  2309. },
  2310. "404": {
  2311. "description": "Not found or not visible to the caller",
  2312. "content": {
  2313. "application/json": {
  2314. "schema": {
  2315. "$ref": "#/components/schemas/Error"
  2316. }
  2317. }
  2318. }
  2319. },
  2320. "500": {
  2321. "description": "Internal error",
  2322. "content": {
  2323. "application/json": {
  2324. "schema": {
  2325. "$ref": "#/components/schemas/Error"
  2326. }
  2327. }
  2328. }
  2329. }
  2330. },
  2331. "description": " Feedback (POST /feedback) on a result's current revision adjusts its rank; such results carry feedback {useful, not_useful, incorrect_or_harmful} and demoted results are named in warnings."
  2332. }
  2333. },
  2334. "/ingestion/jobs": {
  2335. "post": {
  2336. "summary": "Ingest a Markdown/text document (chunked, indexed)",
  2337. "security": [
  2338. {
  2339. "bearerAuth": []
  2340. }
  2341. ],
  2342. "parameters": [
  2343. {
  2344. "name": "Idempotency-Key",
  2345. "in": "header",
  2346. "required": false,
  2347. "description": "Replays the stored response for an identical body; a different body with the same key is 409.",
  2348. "schema": {
  2349. "type": "string",
  2350. "maxLength": 200
  2351. }
  2352. }
  2353. ],
  2354. "requestBody": {
  2355. "required": true,
  2356. "content": {
  2357. "application/json": {
  2358. "schema": {
  2359. "$ref": "#/components/schemas/IngestRequest"
  2360. }
  2361. }
  2362. }
  2363. },
  2364. "responses": {
  2365. "201": {
  2366. "description": "Ingested (new document or new revision)",
  2367. "content": {
  2368. "application/json": {
  2369. "schema": {
  2370. "$ref": "#/components/schemas/IngestResponse"
  2371. }
  2372. }
  2373. }
  2374. },
  2375. "200": {
  2376. "description": "Unchanged or idempotent replay",
  2377. "content": {
  2378. "application/json": {
  2379. "schema": {
  2380. "$ref": "#/components/schemas/IngestResponse"
  2381. }
  2382. }
  2383. }
  2384. },
  2385. "400": {
  2386. "description": "Invalid JSON",
  2387. "content": {
  2388. "application/json": {
  2389. "schema": {
  2390. "$ref": "#/components/schemas/Error"
  2391. }
  2392. }
  2393. }
  2394. },
  2395. "409": {
  2396. "description": "Idempotency-Key reused with a different body",
  2397. "content": {
  2398. "application/json": {
  2399. "schema": {
  2400. "$ref": "#/components/schemas/Error"
  2401. }
  2402. }
  2403. }
  2404. },
  2405. "422": {
  2406. "description": "Validation failed",
  2407. "content": {
  2408. "application/json": {
  2409. "schema": {
  2410. "$ref": "#/components/schemas/Error"
  2411. }
  2412. }
  2413. }
  2414. },
  2415. "401": {
  2416. "description": "Missing, invalid, revoked or expired API key",
  2417. "content": {
  2418. "application/json": {
  2419. "schema": {
  2420. "$ref": "#/components/schemas/Error"
  2421. }
  2422. }
  2423. }
  2424. },
  2425. "404": {
  2426. "description": "Not found or not visible to the caller",
  2427. "content": {
  2428. "application/json": {
  2429. "schema": {
  2430. "$ref": "#/components/schemas/Error"
  2431. }
  2432. }
  2433. }
  2434. },
  2435. "500": {
  2436. "description": "Internal error",
  2437. "content": {
  2438. "application/json": {
  2439. "schema": {
  2440. "$ref": "#/components/schemas/Error"
  2441. }
  2442. }
  2443. }
  2444. }
  2445. }
  2446. }
  2447. },
  2448. "/jobs/{id}": {
  2449. "get": {
  2450. "summary": "Ingestion job state",
  2451. "security": [
  2452. {
  2453. "bearerAuth": []
  2454. }
  2455. ],
  2456. "parameters": [
  2457. {
  2458. "name": "id",
  2459. "in": "path",
  2460. "required": true,
  2461. "schema": {
  2462. "type": "string",
  2463. "format": "uuid"
  2464. }
  2465. }
  2466. ],
  2467. "responses": {
  2468. "200": {
  2469. "description": "Job"
  2470. },
  2471. "401": {
  2472. "description": "Missing, invalid, revoked or expired API key",
  2473. "content": {
  2474. "application/json": {
  2475. "schema": {
  2476. "$ref": "#/components/schemas/Error"
  2477. }
  2478. }
  2479. }
  2480. },
  2481. "404": {
  2482. "description": "Not found or not visible to the caller",
  2483. "content": {
  2484. "application/json": {
  2485. "schema": {
  2486. "$ref": "#/components/schemas/Error"
  2487. }
  2488. }
  2489. }
  2490. },
  2491. "500": {
  2492. "description": "Internal error",
  2493. "content": {
  2494. "application/json": {
  2495. "schema": {
  2496. "$ref": "#/components/schemas/Error"
  2497. }
  2498. }
  2499. }
  2500. }
  2501. }
  2502. }
  2503. },
  2504. "/documents/{id}": {
  2505. "get": {
  2506. "summary": "Document metadata (?include_content=true adds the normalized text)",
  2507. "security": [
  2508. {
  2509. "bearerAuth": []
  2510. }
  2511. ],
  2512. "parameters": [
  2513. {
  2514. "name": "id",
  2515. "in": "path",
  2516. "required": true,
  2517. "schema": {
  2518. "type": "string",
  2519. "format": "uuid"
  2520. }
  2521. },
  2522. {
  2523. "name": "include_content",
  2524. "in": "query",
  2525. "schema": {
  2526. "type": "boolean"
  2527. }
  2528. }
  2529. ],
  2530. "responses": {
  2531. "200": {
  2532. "description": "Document"
  2533. },
  2534. "401": {
  2535. "description": "Missing, invalid, revoked or expired API key",
  2536. "content": {
  2537. "application/json": {
  2538. "schema": {
  2539. "$ref": "#/components/schemas/Error"
  2540. }
  2541. }
  2542. }
  2543. },
  2544. "404": {
  2545. "description": "Not found or not visible to the caller",
  2546. "content": {
  2547. "application/json": {
  2548. "schema": {
  2549. "$ref": "#/components/schemas/Error"
  2550. }
  2551. }
  2552. }
  2553. },
  2554. "500": {
  2555. "description": "Internal error",
  2556. "content": {
  2557. "application/json": {
  2558. "schema": {
  2559. "$ref": "#/components/schemas/Error"
  2560. }
  2561. }
  2562. }
  2563. }
  2564. }
  2565. }
  2566. },
  2567. "/chunks/{id}": {
  2568. "get": {
  2569. "summary": "One chunk with heading path and source locator (character offsets into the normalized document text)",
  2570. "security": [
  2571. {
  2572. "bearerAuth": []
  2573. }
  2574. ],
  2575. "parameters": [
  2576. {
  2577. "name": "id",
  2578. "in": "path",
  2579. "required": true,
  2580. "schema": {
  2581. "type": "string",
  2582. "format": "uuid"
  2583. }
  2584. }
  2585. ],
  2586. "responses": {
  2587. "200": {
  2588. "description": "Chunk"
  2589. },
  2590. "401": {
  2591. "description": "Missing, invalid, revoked or expired API key",
  2592. "content": {
  2593. "application/json": {
  2594. "schema": {
  2595. "$ref": "#/components/schemas/Error"
  2596. }
  2597. }
  2598. }
  2599. },
  2600. "404": {
  2601. "description": "Not found or not visible to the caller",
  2602. "content": {
  2603. "application/json": {
  2604. "schema": {
  2605. "$ref": "#/components/schemas/Error"
  2606. }
  2607. }
  2608. }
  2609. },
  2610. "500": {
  2611. "description": "Internal error",
  2612. "content": {
  2613. "application/json": {
  2614. "schema": {
  2615. "$ref": "#/components/schemas/Error"
  2616. }
  2617. }
  2618. }
  2619. }
  2620. }
  2621. }
  2622. },
  2623. "/search": {
  2624. "post": {
  2625. "summary": "Hybrid search over current document chunks (lexical fused with vector similarity; lexical only, with a warning, when the embedding provider is off or down). Results are untrusted reference content",
  2626. "security": [
  2627. {
  2628. "bearerAuth": []
  2629. }
  2630. ],
  2631. "requestBody": {
  2632. "required": true,
  2633. "content": {
  2634. "application/json": {
  2635. "schema": {
  2636. "$ref": "#/components/schemas/SearchRequest"
  2637. }
  2638. }
  2639. }
  2640. },
  2641. "responses": {
  2642. "200": {
  2643. "description": "Ranked chunks with locators and content_trust"
  2644. },
  2645. "422": {
  2646. "description": "Validation failed",
  2647. "content": {
  2648. "application/json": {
  2649. "schema": {
  2650. "$ref": "#/components/schemas/Error"
  2651. }
  2652. }
  2653. }
  2654. },
  2655. "401": {
  2656. "description": "Missing, invalid, revoked or expired API key",
  2657. "content": {
  2658. "application/json": {
  2659. "schema": {
  2660. "$ref": "#/components/schemas/Error"
  2661. }
  2662. }
  2663. }
  2664. },
  2665. "404": {
  2666. "description": "Not found or not visible to the caller",
  2667. "content": {
  2668. "application/json": {
  2669. "schema": {
  2670. "$ref": "#/components/schemas/Error"
  2671. }
  2672. }
  2673. }
  2674. },
  2675. "500": {
  2676. "description": "Internal error",
  2677. "content": {
  2678. "application/json": {
  2679. "schema": {
  2680. "$ref": "#/components/schemas/Error"
  2681. }
  2682. }
  2683. }
  2684. }
  2685. },
  2686. "description": " Feedback (POST /feedback) on a result's current revision adjusts its rank; such results carry feedback {useful, not_useful, incorrect_or_harmful} and demoted results are named in warnings."
  2687. }
  2688. },
  2689. "/health/live": {
  2690. "get": {
  2691. "summary": "Liveness",
  2692. "responses": {
  2693. "200": {
  2694. "description": "Live"
  2695. }
  2696. }
  2697. }
  2698. },
  2699. "/health/ready": {
  2700. "get": {
  2701. "summary": "Readiness (database reachable)",
  2702. "responses": {
  2703. "200": {
  2704. "description": "Ready"
  2705. },
  2706. "503": {
  2707. "description": "Unavailable"
  2708. }
  2709. }
  2710. }
  2711. },
  2712. "/metrics": {
  2713. "get": {
  2714. "summary": "Prometheus text metrics: API request counters and latency histogram per controller action (since process start), plus installation-wide counts (memories, candidates, jobs, embedding index, retrieval calls, feedback). Counts only. Enabled when the container has AMK_METRICS_TOKEN (16+ characters); send it as a bearer token. API keys are not accepted.",
  2715. "tags": [
  2716. "health"
  2717. ],
  2718. "responses": {
  2719. "200": {
  2720. "description": "Metrics",
  2721. "content": {
  2722. "text/plain": {
  2723. "schema": {
  2724. "type": "string"
  2725. }
  2726. }
  2727. }
  2728. },
  2729. "401": {
  2730. "description": "Missing or wrong metrics token",
  2731. "content": {
  2732. "application/json": {
  2733. "schema": {
  2734. "$ref": "#/components/schemas/Error"
  2735. }
  2736. }
  2737. }
  2738. },
  2739. "404": {
  2740. "description": "Metrics are disabled (no AMK_METRICS_TOKEN)",
  2741. "content": {
  2742. "application/json": {
  2743. "schema": {
  2744. "$ref": "#/components/schemas/Error"
  2745. }
  2746. }
  2747. }
  2748. }
  2749. }
  2750. }
  2751. },
  2752. "/context": {
  2753. "post": {
  2754. "summary": "Assemble a token-budgeted task briefing: constraints by scope, working state, preferences, conflicts, hybrid matches and reference passages",
  2755. "security": [
  2756. {
  2757. "bearerAuth": []
  2758. }
  2759. ],
  2760. "requestBody": {
  2761. "required": true,
  2762. "content": {
  2763. "application/json": {
  2764. "schema": {
  2765. "$ref": "#/components/schemas/ContextRequest"
  2766. }
  2767. }
  2768. }
  2769. },
  2770. "responses": {
  2771. "200": {
  2772. "description": "Briefing",
  2773. "content": {
  2774. "application/json": {
  2775. "schema": {
  2776. "$ref": "#/components/schemas/ContextResponse"
  2777. }
  2778. }
  2779. }
  2780. },
  2781. "400": {
  2782. "description": "Empty body or invalid JSON",
  2783. "content": {
  2784. "application/json": {
  2785. "schema": {
  2786. "$ref": "#/components/schemas/Error"
  2787. }
  2788. }
  2789. }
  2790. },
  2791. "401": {
  2792. "description": "Missing, invalid, revoked or expired API key",
  2793. "content": {
  2794. "application/json": {
  2795. "schema": {
  2796. "$ref": "#/components/schemas/Error"
  2797. }
  2798. }
  2799. }
  2800. },
  2801. "404": {
  2802. "description": "session_id not found or not visible to the caller",
  2803. "content": {
  2804. "application/json": {
  2805. "schema": {
  2806. "$ref": "#/components/schemas/Error"
  2807. }
  2808. }
  2809. }
  2810. },
  2811. "422": {
  2812. "description": "Validation failed, unsupported_character (code points above U+FFFF), or context_budget_exceeded (the applicable constraints do not fit max_context_tokens; the error also carries required_tokens)",
  2813. "content": {
  2814. "application/json": {
  2815. "schema": {
  2816. "$ref": "#/components/schemas/Error"
  2817. }
  2818. }
  2819. }
  2820. },
  2821. "500": {
  2822. "description": "Internal error",
  2823. "content": {
  2824. "application/json": {
  2825. "schema": {
  2826. "$ref": "#/components/schemas/Error"
  2827. }
  2828. }
  2829. }
  2830. }
  2831. }
  2832. }
  2833. },
  2834. "/sessions/{id}/events": {
  2835. "post": {
  2836. "summary": "Record an experience (task, problem, action, result, outcome) in an active session",
  2837. "tags": [
  2838. "learning"
  2839. ],
  2840. "security": [
  2841. {
  2842. "bearerAuth": []
  2843. }
  2844. ],
  2845. "parameters": [
  2846. {
  2847. "name": "id",
  2848. "in": "path",
  2849. "required": true,
  2850. "schema": {
  2851. "type": "string",
  2852. "format": "uuid"
  2853. }
  2854. },
  2855. {
  2856. "name": "Idempotency-Key",
  2857. "in": "header",
  2858. "required": false,
  2859. "schema": {
  2860. "type": "string",
  2861. "maxLength": 200
  2862. },
  2863. "description": "Replays the stored response for a repeated request; 409 if reused with a different body."
  2864. }
  2865. ],
  2866. "requestBody": {
  2867. "required": true,
  2868. "content": {
  2869. "application/json": {
  2870. "schema": {
  2871. "$ref": "#/components/schemas/ExperienceRequest"
  2872. }
  2873. }
  2874. }
  2875. },
  2876. "responses": {
  2877. "201": {
  2878. "description": "Recorded",
  2879. "content": {
  2880. "application/json": {
  2881. "schema": {
  2882. "type": "object",
  2883. "properties": {
  2884. "id": {
  2885. "type": "string"
  2886. },
  2887. "session_id": {
  2888. "type": "string"
  2889. },
  2890. "outcome": {
  2891. "type": "string"
  2892. },
  2893. "created_at": {
  2894. "type": "string"
  2895. }
  2896. }
  2897. }
  2898. }
  2899. }
  2900. },
  2901. "400": {
  2902. "description": "Empty body, invalid JSON or invalid Idempotency-Key",
  2903. "content": {
  2904. "application/json": {
  2905. "schema": {
  2906. "$ref": "#/components/schemas/Error"
  2907. }
  2908. }
  2909. }
  2910. },
  2911. "401": {
  2912. "description": "Missing, invalid, revoked or expired API key",
  2913. "content": {
  2914. "application/json": {
  2915. "schema": {
  2916. "$ref": "#/components/schemas/Error"
  2917. }
  2918. }
  2919. }
  2920. },
  2921. "404": {
  2922. "description": "Session not found, or no write permission on its namespace",
  2923. "content": {
  2924. "application/json": {
  2925. "schema": {
  2926. "$ref": "#/components/schemas/Error"
  2927. }
  2928. }
  2929. }
  2930. },
  2931. "409": {
  2932. "description": "session_not_active (completed session) or idempotency_conflict",
  2933. "content": {
  2934. "application/json": {
  2935. "schema": {
  2936. "$ref": "#/components/schemas/Error"
  2937. }
  2938. }
  2939. }
  2940. },
  2941. "422": {
  2942. "description": "Validation failed or unsupported_character",
  2943. "content": {
  2944. "application/json": {
  2945. "schema": {
  2946. "$ref": "#/components/schemas/Error"
  2947. }
  2948. }
  2949. }
  2950. },
  2951. "500": {
  2952. "description": "Internal error",
  2953. "content": {
  2954. "application/json": {
  2955. "schema": {
  2956. "$ref": "#/components/schemas/Error"
  2957. }
  2958. }
  2959. }
  2960. }
  2961. }
  2962. },
  2963. "get": {
  2964. "summary": "List the experiences of a session, oldest first (max 200)",
  2965. "tags": [
  2966. "learning"
  2967. ],
  2968. "security": [
  2969. {
  2970. "bearerAuth": []
  2971. }
  2972. ],
  2973. "parameters": [
  2974. {
  2975. "name": "id",
  2976. "in": "path",
  2977. "required": true,
  2978. "schema": {
  2979. "type": "string",
  2980. "format": "uuid"
  2981. }
  2982. }
  2983. ],
  2984. "responses": {
  2985. "200": {
  2986. "description": "Experiences",
  2987. "content": {
  2988. "application/json": {
  2989. "schema": {
  2990. "type": "object",
  2991. "properties": {
  2992. "session_id": {
  2993. "type": "string"
  2994. },
  2995. "data": {
  2996. "type": "array",
  2997. "items": {
  2998. "$ref": "#/components/schemas/Experience"
  2999. }
  3000. }
  3001. }
  3002. }
  3003. }
  3004. }
  3005. },
  3006. "401": {
  3007. "description": "Missing, invalid, revoked or expired API key",
  3008. "content": {
  3009. "application/json": {
  3010. "schema": {
  3011. "$ref": "#/components/schemas/Error"
  3012. }
  3013. }
  3014. }
  3015. },
  3016. "404": {
  3017. "description": "Session not found or not readable",
  3018. "content": {
  3019. "application/json": {
  3020. "schema": {
  3021. "$ref": "#/components/schemas/Error"
  3022. }
  3023. }
  3024. }
  3025. },
  3026. "500": {
  3027. "description": "Internal error",
  3028. "content": {
  3029. "application/json": {
  3030. "schema": {
  3031. "$ref": "#/components/schemas/Error"
  3032. }
  3033. }
  3034. }
  3035. }
  3036. }
  3037. }
  3038. },
  3039. "/learn": {
  3040. "post": {
  3041. "summary": "Propose knowledge as a learning candidate (a new memory, or a new revision of target_memory_id at base_revision), with evidence",
  3042. "tags": [
  3043. "learning"
  3044. ],
  3045. "security": [
  3046. {
  3047. "bearerAuth": []
  3048. }
  3049. ],
  3050. "parameters": [
  3051. {
  3052. "name": "Idempotency-Key",
  3053. "in": "header",
  3054. "required": false,
  3055. "schema": {
  3056. "type": "string",
  3057. "maxLength": 200
  3058. },
  3059. "description": "Replays the stored response for a repeated request; 409 if reused with a different body."
  3060. }
  3061. ],
  3062. "requestBody": {
  3063. "required": true,
  3064. "content": {
  3065. "application/json": {
  3066. "schema": {
  3067. "$ref": "#/components/schemas/LearnRequest"
  3068. }
  3069. }
  3070. }
  3071. },
  3072. "responses": {
  3073. "201": {
  3074. "description": "Candidate proposed",
  3075. "content": {
  3076. "application/json": {
  3077. "schema": {
  3078. "type": "object",
  3079. "properties": {
  3080. "id": {
  3081. "type": "string"
  3082. },
  3083. "state": {
  3084. "type": "string",
  3085. "enum": [
  3086. "proposed"
  3087. ]
  3088. },
  3089. "namespace_id": {
  3090. "type": "string"
  3091. },
  3092. "type": {
  3093. "type": "string"
  3094. },
  3095. "evidence_count": {
  3096. "type": "integer"
  3097. }
  3098. }
  3099. }
  3100. }
  3101. }
  3102. },
  3103. "400": {
  3104. "description": "Empty body, invalid JSON or invalid Idempotency-Key",
  3105. "content": {
  3106. "application/json": {
  3107. "schema": {
  3108. "$ref": "#/components/schemas/Error"
  3109. }
  3110. }
  3111. }
  3112. },
  3113. "401": {
  3114. "description": "Missing, invalid, revoked or expired API key",
  3115. "content": {
  3116. "application/json": {
  3117. "schema": {
  3118. "$ref": "#/components/schemas/Error"
  3119. }
  3120. }
  3121. }
  3122. },
  3123. "404": {
  3124. "description": "Namespace not found or no write permission",
  3125. "content": {
  3126. "application/json": {
  3127. "schema": {
  3128. "$ref": "#/components/schemas/Error"
  3129. }
  3130. }
  3131. }
  3132. },
  3133. "409": {
  3134. "description": "idempotency_conflict",
  3135. "content": {
  3136. "application/json": {
  3137. "schema": {
  3138. "$ref": "#/components/schemas/Error"
  3139. }
  3140. }
  3141. }
  3142. },
  3143. "422": {
  3144. "description": "Validation failed (unknown type, bad target/base_revision, evidence that is unknown, in another tenant or not readable by the caller) or unsupported_character",
  3145. "content": {
  3146. "application/json": {
  3147. "schema": {
  3148. "$ref": "#/components/schemas/Error"
  3149. }
  3150. }
  3151. }
  3152. },
  3153. "500": {
  3154. "description": "Internal error",
  3155. "content": {
  3156. "application/json": {
  3157. "schema": {
  3158. "$ref": "#/components/schemas/Error"
  3159. }
  3160. }
  3161. }
  3162. }
  3163. }
  3164. }
  3165. },
  3166. "/candidates": {
  3167. "get": {
  3168. "summary": "List learning candidates in namespaces the caller can read, newest first",
  3169. "tags": [
  3170. "learning"
  3171. ],
  3172. "security": [
  3173. {
  3174. "bearerAuth": []
  3175. }
  3176. ],
  3177. "parameters": [
  3178. {
  3179. "name": "namespace_id",
  3180. "in": "query",
  3181. "schema": {
  3182. "type": "string",
  3183. "format": "uuid"
  3184. }
  3185. },
  3186. {
  3187. "name": "state",
  3188. "in": "query",
  3189. "schema": {
  3190. "type": "string",
  3191. "enum": [
  3192. "proposed",
  3193. "accepted",
  3194. "rejected"
  3195. ]
  3196. }
  3197. },
  3198. {
  3199. "name": "limit",
  3200. "in": "query",
  3201. "schema": {
  3202. "type": "integer",
  3203. "minimum": 1,
  3204. "maximum": 200,
  3205. "default": 50
  3206. }
  3207. }
  3208. ],
  3209. "responses": {
  3210. "200": {
  3211. "description": "Candidates (without content)",
  3212. "content": {
  3213. "application/json": {
  3214. "schema": {
  3215. "type": "object",
  3216. "properties": {
  3217. "data": {
  3218. "type": "array",
  3219. "items": {
  3220. "$ref": "#/components/schemas/Candidate"
  3221. }
  3222. }
  3223. }
  3224. }
  3225. }
  3226. }
  3227. },
  3228. "401": {
  3229. "description": "Missing, invalid, revoked or expired API key",
  3230. "content": {
  3231. "application/json": {
  3232. "schema": {
  3233. "$ref": "#/components/schemas/Error"
  3234. }
  3235. }
  3236. }
  3237. },
  3238. "422": {
  3239. "description": "Bad state or namespace_id",
  3240. "content": {
  3241. "application/json": {
  3242. "schema": {
  3243. "$ref": "#/components/schemas/Error"
  3244. }
  3245. }
  3246. }
  3247. },
  3248. "500": {
  3249. "description": "Internal error",
  3250. "content": {
  3251. "application/json": {
  3252. "schema": {
  3253. "$ref": "#/components/schemas/Error"
  3254. }
  3255. }
  3256. }
  3257. }
  3258. }
  3259. }
  3260. },
  3261. "/candidates/{id}": {
  3262. "get": {
  3263. "summary": "One candidate with content and evidence",
  3264. "tags": [
  3265. "learning"
  3266. ],
  3267. "security": [
  3268. {
  3269. "bearerAuth": []
  3270. }
  3271. ],
  3272. "parameters": [
  3273. {
  3274. "name": "id",
  3275. "in": "path",
  3276. "required": true,
  3277. "schema": {
  3278. "type": "string",
  3279. "format": "uuid"
  3280. }
  3281. }
  3282. ],
  3283. "responses": {
  3284. "200": {
  3285. "description": "Candidate",
  3286. "content": {
  3287. "application/json": {
  3288. "schema": {
  3289. "type": "object",
  3290. "properties": {
  3291. "data": {
  3292. "$ref": "#/components/schemas/Candidate"
  3293. }
  3294. }
  3295. }
  3296. }
  3297. }
  3298. },
  3299. "401": {
  3300. "description": "Missing, invalid, revoked or expired API key",
  3301. "content": {
  3302. "application/json": {
  3303. "schema": {
  3304. "$ref": "#/components/schemas/Error"
  3305. }
  3306. }
  3307. }
  3308. },
  3309. "404": {
  3310. "description": "Not found or not readable",
  3311. "content": {
  3312. "application/json": {
  3313. "schema": {
  3314. "$ref": "#/components/schemas/Error"
  3315. }
  3316. }
  3317. }
  3318. },
  3319. "500": {
  3320. "description": "Internal error",
  3321. "content": {
  3322. "application/json": {
  3323. "schema": {
  3324. "$ref": "#/components/schemas/Error"
  3325. }
  3326. }
  3327. }
  3328. }
  3329. }
  3330. }
  3331. },
  3332. "/candidates/{id}/review": {
  3333. "post": {
  3334. "summary": "Accept or reject a proposed candidate. Needs verify permission; the author cannot review its own candidate without admin. Accepting creates the memory (an identical active memory is reused) or a new revision of the target, copies the evidence and, with verify true, records a verification by the reviewer.",
  3335. "tags": [
  3336. "learning"
  3337. ],
  3338. "security": [
  3339. {
  3340. "bearerAuth": []
  3341. }
  3342. ],
  3343. "parameters": [
  3344. {
  3345. "name": "id",
  3346. "in": "path",
  3347. "required": true,
  3348. "schema": {
  3349. "type": "string",
  3350. "format": "uuid"
  3351. }
  3352. }
  3353. ],
  3354. "requestBody": {
  3355. "required": true,
  3356. "content": {
  3357. "application/json": {
  3358. "schema": {
  3359. "$ref": "#/components/schemas/ReviewRequest"
  3360. }
  3361. }
  3362. }
  3363. },
  3364. "responses": {
  3365. "200": {
  3366. "description": "Reviewed",
  3367. "content": {
  3368. "application/json": {
  3369. "schema": {
  3370. "type": "object",
  3371. "properties": {
  3372. "id": {
  3373. "type": "string"
  3374. },
  3375. "state": {
  3376. "type": "string",
  3377. "enum": [
  3378. "accepted",
  3379. "rejected"
  3380. ]
  3381. },
  3382. "resulting_memory_id": {
  3383. "type": "string"
  3384. },
  3385. "resulting_revision": {
  3386. "type": "integer"
  3387. },
  3388. "verification_status": {
  3389. "type": "string"
  3390. },
  3391. "duplicate": {
  3392. "type": "boolean"
  3393. }
  3394. }
  3395. }
  3396. }
  3397. }
  3398. },
  3399. "400": {
  3400. "description": "Empty body or invalid JSON",
  3401. "content": {
  3402. "application/json": {
  3403. "schema": {
  3404. "$ref": "#/components/schemas/Error"
  3405. }
  3406. }
  3407. }
  3408. },
  3409. "401": {
  3410. "description": "Missing, invalid, revoked or expired API key",
  3411. "content": {
  3412. "application/json": {
  3413. "schema": {
  3414. "$ref": "#/components/schemas/Error"
  3415. }
  3416. }
  3417. }
  3418. },
  3419. "403": {
  3420. "description": "self_review_not_allowed",
  3421. "content": {
  3422. "application/json": {
  3423. "schema": {
  3424. "$ref": "#/components/schemas/Error"
  3425. }
  3426. }
  3427. }
  3428. },
  3429. "404": {
  3430. "description": "Candidate not found or no verify permission",
  3431. "content": {
  3432. "application/json": {
  3433. "schema": {
  3434. "$ref": "#/components/schemas/Error"
  3435. }
  3436. }
  3437. }
  3438. },
  3439. "409": {
  3440. "description": "candidate_already_reviewed, stale_candidate (target memory changed since base_revision), target_memory_missing or target_memory_not_active",
  3441. "content": {
  3442. "application/json": {
  3443. "schema": {
  3444. "$ref": "#/components/schemas/Error"
  3445. }
  3446. }
  3447. }
  3448. },
  3449. "422": {
  3450. "description": "Validation failed",
  3451. "content": {
  3452. "application/json": {
  3453. "schema": {
  3454. "$ref": "#/components/schemas/Error"
  3455. }
  3456. }
  3457. }
  3458. },
  3459. "500": {
  3460. "description": "Internal error",
  3461. "content": {
  3462. "application/json": {
  3463. "schema": {
  3464. "$ref": "#/components/schemas/Error"
  3465. }
  3466. }
  3467. }
  3468. }
  3469. }
  3470. }
  3471. },
  3472. "/memories/{id}/sources": {
  3473. "get": {
  3474. "summary": "Evidence and verifications behind a memory revision. Evidence the caller cannot read is listed with available false and no id.",
  3475. "tags": [
  3476. "learning"
  3477. ],
  3478. "security": [
  3479. {
  3480. "bearerAuth": []
  3481. }
  3482. ],
  3483. "parameters": [
  3484. {
  3485. "name": "id",
  3486. "in": "path",
  3487. "required": true,
  3488. "schema": {
  3489. "type": "string",
  3490. "format": "uuid"
  3491. }
  3492. },
  3493. {
  3494. "name": "revision",
  3495. "in": "query",
  3496. "schema": {
  3497. "type": "integer",
  3498. "minimum": 1
  3499. },
  3500. "description": "Default: current revision"
  3501. }
  3502. ],
  3503. "responses": {
  3504. "200": {
  3505. "description": "Sources",
  3506. "content": {
  3507. "application/json": {
  3508. "schema": {
  3509. "$ref": "#/components/schemas/Sources"
  3510. }
  3511. }
  3512. }
  3513. },
  3514. "401": {
  3515. "description": "Missing, invalid, revoked or expired API key",
  3516. "content": {
  3517. "application/json": {
  3518. "schema": {
  3519. "$ref": "#/components/schemas/Error"
  3520. }
  3521. }
  3522. }
  3523. },
  3524. "404": {
  3525. "description": "Memory not found or not readable",
  3526. "content": {
  3527. "application/json": {
  3528. "schema": {
  3529. "$ref": "#/components/schemas/Error"
  3530. }
  3531. }
  3532. }
  3533. },
  3534. "422": {
  3535. "description": "revision out of range",
  3536. "content": {
  3537. "application/json": {
  3538. "schema": {
  3539. "$ref": "#/components/schemas/Error"
  3540. }
  3541. }
  3542. }
  3543. },
  3544. "500": {
  3545. "description": "Internal error",
  3546. "content": {
  3547. "application/json": {
  3548. "schema": {
  3549. "$ref": "#/components/schemas/Error"
  3550. }
  3551. }
  3552. }
  3553. }
  3554. }
  3555. }
  3556. },
  3557. "/feedback": {
  3558. "post": {
  3559. "summary": "Rate one result of a recall, search or context call (by its query_id). One rating per principal, query and result; a new rating replaces the earlier one (200). Pinned to the revision that was returned.",
  3560. "tags": [
  3561. "learning"
  3562. ],
  3563. "security": [
  3564. {
  3565. "bearerAuth": []
  3566. }
  3567. ],
  3568. "requestBody": {
  3569. "required": true,
  3570. "content": {
  3571. "application/json": {
  3572. "schema": {
  3573. "$ref": "#/components/schemas/FeedbackRequest"
  3574. }
  3575. }
  3576. }
  3577. },
  3578. "responses": {
  3579. "200": {
  3580. "description": "Updated",
  3581. "content": {
  3582. "application/json": {
  3583. "schema": {
  3584. "$ref": "#/components/schemas/Feedback"
  3585. }
  3586. }
  3587. }
  3588. },
  3589. "201": {
  3590. "description": "Recorded",
  3591. "content": {
  3592. "application/json": {
  3593. "schema": {
  3594. "$ref": "#/components/schemas/Feedback"
  3595. }
  3596. }
  3597. }
  3598. },
  3599. "400": {
  3600. "description": "Empty body or invalid JSON",
  3601. "content": {
  3602. "application/json": {
  3603. "schema": {
  3604. "$ref": "#/components/schemas/Error"
  3605. }
  3606. }
  3607. }
  3608. },
  3609. "401": {
  3610. "description": "Missing, invalid, revoked or expired API key",
  3611. "content": {
  3612. "application/json": {
  3613. "schema": {
  3614. "$ref": "#/components/schemas/Error"
  3615. }
  3616. }
  3617. }
  3618. },
  3619. "404": {
  3620. "description": "result_not_found: the result was not returned by that query, is gone, or is not readable",
  3621. "content": {
  3622. "application/json": {
  3623. "schema": {
  3624. "$ref": "#/components/schemas/Error"
  3625. }
  3626. }
  3627. }
  3628. },
  3629. "422": {
  3630. "description": "Validation failed",
  3631. "content": {
  3632. "application/json": {
  3633. "schema": {
  3634. "$ref": "#/components/schemas/Error"
  3635. }
  3636. }
  3637. }
  3638. },
  3639. "500": {
  3640. "description": "Internal error",
  3641. "content": {
  3642. "application/json": {
  3643. "schema": {
  3644. "$ref": "#/components/schemas/Error"
  3645. }
  3646. }
  3647. }
  3648. }
  3649. }
  3650. }
  3651. },
  3652. "/exports": {
  3653. "post": {
  3654. "summary": "Export every namespace the caller can read (or the namespace_ids given) as one canonical, integrity-protected JSON document. Evidence whose target the caller cannot read is left out and counted in counts.evidence_links_omitted. Sent as an attachment.",
  3655. "tags": [
  3656. "portability"
  3657. ],
  3658. "security": [
  3659. {
  3660. "bearerAuth": []
  3661. }
  3662. ],
  3663. "requestBody": {
  3664. "required": false,
  3665. "content": {
  3666. "application/json": {
  3667. "schema": {
  3668. "$ref": "#/components/schemas/ExportRequest"
  3669. }
  3670. }
  3671. }
  3672. },
  3673. "responses": {
  3674. "200": {
  3675. "description": "The export document",
  3676. "content": {
  3677. "application/json": {
  3678. "schema": {
  3679. "$ref": "#/components/schemas/Export"
  3680. }
  3681. }
  3682. }
  3683. },
  3684. "400": {
  3685. "description": "Invalid JSON",
  3686. "content": {
  3687. "application/json": {
  3688. "schema": {
  3689. "$ref": "#/components/schemas/Error"
  3690. }
  3691. }
  3692. }
  3693. },
  3694. "401": {
  3695. "description": "Missing, invalid, revoked or expired API key",
  3696. "content": {
  3697. "application/json": {
  3698. "schema": {
  3699. "$ref": "#/components/schemas/Error"
  3700. }
  3701. }
  3702. }
  3703. },
  3704. "422": {
  3705. "description": "Validation failed (namespace_ids is not an array of ids)",
  3706. "content": {
  3707. "application/json": {
  3708. "schema": {
  3709. "$ref": "#/components/schemas/Error"
  3710. }
  3711. }
  3712. }
  3713. },
  3714. "500": {
  3715. "description": "Internal error",
  3716. "content": {
  3717. "application/json": {
  3718. "schema": {
  3719. "$ref": "#/components/schemas/Error"
  3720. }
  3721. }
  3722. }
  3723. }
  3724. }
  3725. }
  3726. },
  3727. "/imports": {
  3728. "post": {
  3729. "summary": "Import a document produced by POST /exports, unchanged (max 8 MiB). Needs admin on every target namespace, matched by path in the caller's tenant (they must exist). Ids, revisions, timestamps and principal ids are kept; content hashes and the lexical index are rebuilt and embeddings are queued. All or nothing.",
  3730. "tags": [
  3731. "portability"
  3732. ],
  3733. "security": [
  3734. {
  3735. "bearerAuth": []
  3736. }
  3737. ],
  3738. "requestBody": {
  3739. "required": true,
  3740. "content": {
  3741. "application/json": {
  3742. "schema": {
  3743. "$ref": "#/components/schemas/Export"
  3744. }
  3745. }
  3746. }
  3747. },
  3748. "responses": {
  3749. "201": {
  3750. "description": "Imported",
  3751. "content": {
  3752. "application/json": {
  3753. "schema": {
  3754. "$ref": "#/components/schemas/ImportResult"
  3755. }
  3756. }
  3757. }
  3758. },
  3759. "400": {
  3760. "description": "Empty body or invalid JSON",
  3761. "content": {
  3762. "application/json": {
  3763. "schema": {
  3764. "$ref": "#/components/schemas/Error"
  3765. }
  3766. }
  3767. }
  3768. },
  3769. "401": {
  3770. "description": "Missing, invalid, revoked or expired API key",
  3771. "content": {
  3772. "application/json": {
  3773. "schema": {
  3774. "$ref": "#/components/schemas/Error"
  3775. }
  3776. }
  3777. }
  3778. },
  3779. "409": {
  3780. "description": "import_conflict: an id in the document already exists; nothing was imported",
  3781. "content": {
  3782. "application/json": {
  3783. "schema": {
  3784. "$ref": "#/components/schemas/Error"
  3785. }
  3786. }
  3787. }
  3788. },
  3789. "413": {
  3790. "description": "body_too_large: more than 8 MiB",
  3791. "content": {
  3792. "application/json": {
  3793. "schema": {
  3794. "$ref": "#/components/schemas/Error"
  3795. }
  3796. }
  3797. }
  3798. },
  3799. "422": {
  3800. "description": "Validation failed: wrong format, unsupported_schema_version, integrity_mismatch, a missing target namespace, no admin permission on it, or an invalid item; nothing was imported",
  3801. "content": {
  3802. "application/json": {
  3803. "schema": {
  3804. "$ref": "#/components/schemas/Error"
  3805. }
  3806. }
  3807. }
  3808. },
  3809. "500": {
  3810. "description": "Internal error; nothing was imported",
  3811. "content": {
  3812. "application/json": {
  3813. "schema": {
  3814. "$ref": "#/components/schemas/Error"
  3815. }
  3816. }
  3817. }
  3818. }
  3819. }
  3820. }
  3821. }
  3822. }
  3823. }

Powered by TurnKey Linux.