@debian777/kairos-mcp 3.3.3 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -105
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/commands/mint.d.ts.map +1 -1
- package/dist/cli/commands/mint.js +9 -1
- package/dist/cli/commands/mint.js.map +1 -1
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002001.md +124 -162
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002002.md +36 -34
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002003.md +195 -0
- package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002004.md +240 -0
- package/dist/embed-docs/mem/README.md +24 -0
- package/dist/resources/docs-resources.d.ts.map +1 -1
- package/dist/resources/docs-resources.js +9 -1
- package/dist/resources/docs-resources.js.map +1 -1
- package/dist/resources/embedded-mcp-resources.d.ts +14 -0
- package/dist/resources/embedded-mcp-resources.d.ts.map +1 -1
- package/dist/resources/embedded-mcp-resources.js +33 -9
- package/dist/resources/embedded-mcp-resources.js.map +1 -1
- package/dist/resources/mem-resources-boot.d.ts.map +1 -1
- package/dist/resources/mem-resources-boot.js +11 -3
- package/dist/resources/mem-resources-boot.js.map +1 -1
- package/dist/services/chain-step-count.d.ts +23 -0
- package/dist/services/chain-step-count.d.ts.map +1 -0
- package/dist/services/chain-step-count.js +23 -0
- package/dist/services/chain-step-count.js.map +1 -0
- package/dist/services/chain-utils.d.ts.map +1 -1
- package/dist/services/chain-utils.js +14 -9
- package/dist/services/chain-utils.js.map +1 -1
- package/dist/services/memory/store-methods.d.ts.map +1 -1
- package/dist/services/memory/store-methods.js +20 -12
- package/dist/services/memory/store-methods.js.map +1 -1
- package/dist/services/qdrant/memory-retrieval.d.ts +6 -1
- package/dist/services/qdrant/memory-retrieval.d.ts.map +1 -1
- package/dist/services/qdrant/memory-retrieval.js +21 -3
- package/dist/services/qdrant/memory-retrieval.js.map +1 -1
- package/dist/services/qdrant/service.d.ts +1 -1
- package/dist/services/qdrant/service.d.ts.map +1 -1
- package/dist/services/qdrant/service.js +2 -2
- package/dist/services/qdrant/service.js.map +1 -1
- package/dist/tools/kairos-challenge-display.d.ts.map +1 -1
- package/dist/tools/kairos-challenge-display.js +32 -2
- package/dist/tools/kairos-challenge-display.js.map +1 -1
- package/dist/tools/kairos_begin.d.ts +5 -0
- package/dist/tools/kairos_begin.d.ts.map +1 -1
- package/dist/tools/kairos_begin.js +8 -8
- package/dist/tools/kairos_begin.js.map +1 -1
- package/dist/tools/kairos_begin_schema.d.ts +5 -0
- package/dist/tools/kairos_begin_schema.d.ts.map +1 -1
- package/dist/tools/kairos_begin_schema.js +6 -1
- package/dist/tools/kairos_begin_schema.js.map +1 -1
- package/dist/tools/kairos_dump.js +1 -1
- package/dist/tools/kairos_dump.js.map +1 -1
- package/dist/tools/kairos_next-previous-step.d.ts.map +1 -1
- package/dist/tools/kairos_next-previous-step.js +11 -3
- package/dist/tools/kairos_next-previous-step.js.map +1 -1
- package/dist/tools/kairos_next_schema.d.ts +5 -0
- package/dist/tools/kairos_next_schema.d.ts.map +1 -1
- package/dist/tools/kairos_next_schema.js +7 -1
- package/dist/tools/kairos_next_schema.js.map +1 -1
- package/dist/tools/shell-challenge-invocation.d.ts +32 -0
- package/dist/tools/shell-challenge-invocation.d.ts.map +1 -0
- package/dist/tools/shell-challenge-invocation.js +113 -0
- package/dist/tools/shell-challenge-invocation.js.map +1 -0
- package/dist/types/memory.d.ts +10 -0
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/ui/assets/{AccountPage-kxmPtqQP.js → AccountPage-BL4GHk9f.js} +1 -1
- package/dist/ui/assets/{ErrorAlert-ME7tEJ6X.js → ErrorAlert-KEgeKl22.js} +1 -1
- package/dist/ui/assets/{HomePage-DxiAsvs-.js → HomePage-DWAvtfBC.js} +1 -1
- package/dist/ui/assets/KairosPage-DZpZ35yd.js +1 -0
- package/dist/ui/assets/NotFoundPage-BrPNDuhe.js +1 -0
- package/dist/ui/assets/{ProtocolDetailPage-DKaSVepL.js → ProtocolDetailPage-R0XlRsIa.js} +1 -1
- package/dist/ui/assets/ProtocolEditPage-CzAnruE6.js +5 -0
- package/dist/ui/assets/{RenderedMarkdown-DjbuQlBl.js → RenderedMarkdown-CMavJdAJ.js} +1 -1
- package/dist/ui/assets/RunGuidedPage-Cm68aCC7.js +1 -0
- package/dist/ui/assets/{RunsPage-ctnsEF2U.js → RunsPage-DcDoMCq1.js} +1 -1
- package/dist/ui/assets/{SkillBundlePage-CaWW5oGq.js → SkillBundlePage-LuYOnVDQ.js} +1 -1
- package/dist/ui/assets/index-0G3wloMr.css +2 -0
- package/dist/ui/assets/index-S4_XWO39.js +8 -0
- package/dist/ui/assets/{tiptap-kMFBDujG.js → tiptap-CzV8H9Mb.js} +22 -22
- package/dist/ui/assets/useProtocol-C3ClZHlN.js +4 -0
- package/dist/ui/assets/{useSpaces-BV6eUjY3.js → useSpaces-DQEfGh8E.js} +1 -1
- package/dist/ui/assets/{vendor-GiUVcjs7.js → vendor-CVpIjmrD.js} +1 -1
- package/dist/ui/index.html +4 -4
- package/dist/utils/space-filter.d.ts +8 -0
- package/dist/utils/space-filter.d.ts.map +1 -1
- package/dist/utils/space-filter.js +18 -0
- package/dist/utils/space-filter.js.map +1 -1
- package/package.json +2 -1
- package/dist/ui/assets/KairosPage-BkqYs3-_.js +0 -1
- package/dist/ui/assets/NotFoundPage-DyfbQ-6G.js +0 -1
- package/dist/ui/assets/ProtocolEditPage-D-aTavvx.js +0 -1
- package/dist/ui/assets/RunGuidedPage-BUD0MaGh.js +0 -1
- package/dist/ui/assets/index-Duu55PkQ.css +0 -2
- package/dist/ui/assets/index-bQSxsGMU.js +0 -8
- package/dist/ui/assets/useProtocol-BruWpIzq.js +0 -4
|
@@ -12,23 +12,29 @@ export const mcpResources = {
|
|
|
12
12
|
"contextual-prompt": "You are KAIROS — a deterministic execution engine for protocol chains.\n\nYou turn user intent into a KAIROS protocol run, then execute it exactly.\nProtocols are stored as memory chains. Each step can define a challenge.\nYou advance a protocol by submitting a matching solution.\n\n**Execution policy:** When running KAIROS protocols, follow the tools'\n`next_action` and `challenge.description` exactly. Do not invent work or\nskip steps. Respond to the user only after the protocol run is complete\n(after calling `kairos_attest` when `next_action` directs you to it).\n\n**Authority:** The tool descriptions for `kairos_search`, `kairos_begin`,\n`kairos_next`, and `kairos_attest` contain all execution rules (challenge\ntypes, nonce and proof_hash echoing, minting). Read them; they are\nauthoritative.\n"
|
|
13
13
|
},
|
|
14
14
|
"resources": {
|
|
15
|
-
"building-kairos-workflows": "# Building KAIROS workflows with challenge/solution\n\n**Purpose:** Primary guide for building KAIROS protocol workflows.\nChallenge/solution is the core mechanism: each step defines a\n**challenge** (what must be done); execution advances by submitting a\nmatching **solution** via `kairos_next`. This guide covers document\nstructure, minting with `kairos_mint`, and solution submission.\n\n---\n\n## Mission\n\nBuild KAIROS protocol workflows where challenges (defined per step) are\nvalidated by solutions (submitted in `kairos_next`). Create documents\nwith `kairos_mint` that define these challenges; maintain exact\nconsistency between markdown structure and memory chain behavior.\n\n---\n\n## Structure\n\n**Document organization:**\n\n- **H1 (`# Title`)** — defines a protocol chain (one H1 = one chain).\n- **Steps** — defined by a trailing ` ```json ` block with\n `{\"challenge\": {...}}`. H2 headings are used as step labels when\n present in a segment.\n- **Challenge** — a fenced ` ```json ` block with `{\"challenge\": {...}}`\n (same shape as `kairos_begin`/`kairos_next`).\n\n**Memory mapping:**\n\n- Each H1 section → one protocol chain.\n- Each challenge block (` ```json ` with `challenge` key) → one memory\n step; content before that block is the step's text.\n- Optional content after the last challenge block → final step (no\n proof required).\n- H2 in a segment → used as that step's label when present.\n\n**Processing flow:**\n\n```\nMarkdown document\n ↓\nkairos_mint(markdown_doc, llm_model_id)\n ↓\nMemory chain (array of memory objects)\n ↓\nEach memory has:\n - memory_uuid\n - label (from H2 heading)\n - text (H2 content)\n - proof_of_work (from trailing JSON challenge block)\n```\n\n---\n\n## Challenge definitions\n\nAdd a trailing ` ```json ` block at the end of each step with an object\nthat has a `challenge` key. The value is the same shape as the challenge\nreturned by `kairos_begin`/`kairos_next`; it round-trips with\n`kairos_dump`.\n\n**`shell`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": { \"cmd\": \"echo \\\"test\\\"\", \"timeout_seconds\": 30 },\n \"required\": true\n }\n}\n```\n\n**`mcp`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"mcp\",\n \"mcp\": { \"tool_name\": \"tool_name\", \"expected_result\": null },\n \"required\": true\n }\n}\n```\n\n**`user_input`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"user_input\",\n \"user_input\": { \"prompt\": \"Confirm completion\" },\n \"required\": true\n }\n}\n```\n\n**`comment`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n**Parsing rule:** Only the **last** fenced code block in a step is read;\nit must be valid JSON with a `challenge` key. The block is stripped from\nstored text; the challenge becomes that step's `proof_of_work`.\n\n### Challenge execution semantics\n\n- **`shell`:** Run the command; report `exit_code`/`stdout`/`stderr`.\n Exit code 0 = success.\n- **`mcp`:** Call the tool; report `result` and `success`.\n- **`user_input`:** Display the prompt to the user; place only their\n reply in `user_input.confirmation`.\n- **`comment`:** Provide text meeting the minimum length; the server\n validates relevance to the step.\n\nFor agent execution rules (what agents must do per type), see the\n`kairos_begin` and `kairos_next` tool descriptions.\n\n---\n\n## MUST ALWAYS\n\n**Document structure:**\n\n- Use H1 (`# Title`) for protocol chain labels.\n- Use H2 (`## Step N`) for individual steps.\n- Place challenge markers **within** the H2 section they apply to.\n\n**Challenge placement:**\n\n- Place the challenge at the **end** of an H2 section as a single\n trailing ` ```json ` block.\n- Only the **last** code block in a step is parsed as the challenge.\n- Ensure the opening \\`\\`\\`json is at **line start** (on its own line,\n no prefix). Blocks with text on the same line (e.g. `Example: \\`\\`\\`json`)\n are not parsed as steps.\n\n**`kairos_mint` usage:**\n\n- Pass `markdown_doc` as a string.\n- Include `llm_model_id` (e.g. `\"minimax/minimax-m2:free\"`).\n- Use `force_update: true` to overwrite existing chains with the same\n label.\n\n**Solution submission:**\n\n- Submit via `kairos_next(uri, solution)`.\n- Solution structure by type:\n - `shell`: `{ type: \"shell\", shell: { exit_code, stdout, stderr,\n duration_seconds } }`\n - `mcp`: `{ type: \"mcp\", mcp: { tool_name, arguments, result,\n success } }`\n - `user_input`: `{ type: \"user_input\", user_input: { confirmation,\n timestamp } }`\n - `comment`: `{ type: \"comment\", comment: { text } }`\n\n---\n\n## MUST NEVER\n\n**Document structure:**\n\n- Mix H1 and H2 in unpredictable ways.\n- Place the challenge JSON block outside the H2 section it ends.\n- Use legacy line-based challenge syntax; use only the trailing JSON\n block.\n\n**Challenge definitions:**\n\n- Use the deprecated `proof_of_work` field in API calls; use `solution`\n instead.\n- Submit solutions that do not match the challenge type.\n\n**`kairos_mint`:**\n\n- Pass `markdown_doc` as an object — always pass as a string.\n- Omit `llm_model_id` — it is required.\n- Store duplicate chains without `force_update: true`.\n\n**Workflow:**\n\n- Confuse `challenge` (output from `kairos_next`) with `solution` (input\n to `kairos_next`).\n- Use the deprecated `proof_of_work` field; use `solution`.\n- Assume step 1 requires a solution submission — step 1 is begun with\n `kairos_begin` only.\n\n---\n\n## Workflow examples\n\n### Example 1: Simple protocol with shell challenges\n\nUse one H1, then one H2 per step. End each step with a ` ```json `\nblock containing `{\"challenge\": {...}}`:\n\n```\n## Step 1: Initialize\nCreate the project structure.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"mkdir -p project/src\",\"timeout_seconds\":10},\"required\":true}}\n```\n```\n\nRepeat for Steps 2 and 3 with their own `shell` challenge blocks.\n\n**Execution flow:**\n\n1. `kairos_search(\"simple setup\")` → returns `must_obey: true` with\n `next_action` containing URI.\n2. `kairos_begin(uri)` → returns step 1 with `challenge` and\n `next_action` with next URI.\n3. `kairos_next(step2_uri, { type: \"shell\", proof_hash: \"...\",\n shell: {...} })` → returns step 2.\n4. Continue through all steps; echo `proof_hash` from each response.\n5. Last `kairos_next` returns `next_action` to call `kairos_attest`.\n Call it to complete the run.\n\n### Example 2: Protocol with comment and user_input challenges\n\nStep 1 ends with a `comment` challenge block; Step 2 with a\n`user_input` block.\n\nStep 1 markdown:\n\n```\n## Step 1: Review\nReview the documentation for accuracy.\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":50},\"required\":true}}\n```\n```\n\nStep 2 markdown:\n\n```\n## Step 2: Confirm\nConfirm review is complete.\n\n```json\n{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"Type 'approved' to confirm\"},\"required\":true}}\n```\n```\n\n### Example 3: Multi-chain document\n\nUse two H1 sections (Protocol A, Protocol B). Each H1 creates a\nseparate chain. Each chain has one or more H2 steps; each step ends with\na ` ```json ` challenge block.\n\n**Result:** Two separate protocol chains are created.\n\n---\n\n## Challenge vs solution nomenclature\n\n- **Challenge** = what `kairos_next` **returns** (what the agent must\n complete).\n- **Solution** = what you **submit** to `kairos_next` (proof you\n completed it).\n\nIn markdown: use a trailing ` ```json ` block with `{\"challenge\": {...}}`\nper step. The API uses `challenge` (output) and `solution` (input).\n\n---\n\n## Validation rules\n\n| Type | Pass condition |\n|------|----------------|\n| `shell` | `exit_code === 0` |\n| `mcp` | `success === true` |\n| `user_input` | Any non-empty `confirmation` |\n| `comment` | `text.length` ≥ `challenge.comment.min_length` |\n\n**Step progression:**\n\n- Step 1: no solution required — call `kairos_begin` only.\n- Steps 2+: solution required — submit matching `solution`.\n- Include `nonce` and `proof_hash` in solution (echo from\n challenge/response).\n- Last step: `kairos_next` directs to `kairos_attest`; call attest to\n finalize.\n\n**Error handling (two-phase retry):**\n\n- Retries 1–3: `must_obey: true` with `error_code` and `next_action`\n for recovery.\n- After 3 retries: `must_obey: false` — choose to fix the step, abort,\n or ask the user.\n- Error responses include `error_code` (e.g. `NONCE_MISMATCH`,\n `TYPE_MISMATCH`) and `retry_count`.\n\n---\n\n## Quick reference\n\n| Operation | Tool | Required fields |\n|-----------|------|-----------------|\n| Mint document | `kairos_mint` | `markdown_doc`, `llm_model_id` |\n| Find protocol | `kairos_search` | `query` |\n| Start protocol | `kairos_begin` | `uri` (from `next_action`) |\n| Continue step | `kairos_next` | `uri` (from `next_action`), `solution` with `nonce` + `proof_hash` |\n| Complete protocol | `kairos_attest` | `uri`, `outcome`, `message` |\n"
|
|
15
|
+
"building-kairos-workflows": "# Building KAIROS workflows with challenge/solution\n\n**Purpose:** Primary guide for building KAIROS protocol workflows.\nChallenge/solution is the core mechanism: each step defines a\n**challenge** (what must be done); execution advances by submitting a\nmatching **solution** via `kairos_next`. This guide covers document\nstructure, minting with `kairos_mint`, and solution submission.\n\n---\n\n## Mission\n\nBuild KAIROS protocol workflows where challenges (defined per step) are\nvalidated by solutions (submitted in `kairos_next`). Create documents\nwith `kairos_mint` that define these challenges; maintain exact\nconsistency between markdown structure and memory chain behavior.\n\n---\n\n## Structure\n\n**Document organization:**\n\n- **H1 (`# Title`)** — defines a protocol chain (one H1 = one chain).\n- **Steps** — defined by a trailing ` ```json ` block with\n `{\"challenge\": {...}}`. H2 headings are used as step labels when\n present in a segment.\n- **Challenge** — a fenced ` ```json ` block with `{\"challenge\": {...}}`\n (same shape as `kairos_begin`/`kairos_next`).\n\n**Memory mapping:**\n\n- Each H1 section → one protocol chain.\n- Each challenge block (` ```json ` with `challenge` key) → one memory\n step; content before that block is the step's text.\n- Optional content after the last challenge block → final step (no\n proof required).\n- H2 in a segment → used as that step's label when present.\n\n**Processing flow:**\n\n```\nMarkdown document\n ↓\nkairos_mint(markdown_doc, llm_model_id)\n ↓\nMemory chain (array of memory objects)\n ↓\nEach memory has:\n - memory_uuid\n - label (from H2 heading)\n - text (H2 content)\n - proof_of_work (from trailing JSON challenge block)\n```\n\n---\n\n## Challenge definitions\n\nAdd a trailing ` ```json ` block at the end of each step with an object\nthat has a `challenge` key. The value is the same shape as the challenge\nreturned by `kairos_begin`/`kairos_next`; it round-trips with\n`kairos_dump`.\n\n**`shell`:**\n\nRequired: `shell.cmd`, `shell.timeout_seconds`. Optional: `interpreter`\n(default bash via `bash -c`), `flags` (interpreter flags; do not duplicate\nauto-injected `-c` / `-e` where applicable), `args` (extra argv after the\nscript segment, e.g. bash `--` positional args), `workdir` (cwd for the\nexecutor after expanding env vars such as `$KAIROS_WORK_DIR`). The server\ndoes not run the command; agents build argv from these fields (see\n`challenge.invocation_display` when present) and must capture **stdout and\nstderr**. If `interpreter` is set, verify it exists on PATH (e.g.\n`which`) before running.\n\nDefault (bash) example: ```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": { \"cmd\": \"echo \\\"test\\\"\", \"timeout_seconds\": 30 },\n \"required\": true\n }\n}\n```\n\nWith `interpreter` (e.g. Perl): ```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": {\n \"interpreter\": \"perl\",\n \"flags\": [\"-00\", \"-ne\"],\n \"cmd\": \"die \\\"bad\\\" unless /^## /m;\",\n \"args\": [\"draft.md\"],\n \"timeout_seconds\": 10\n },\n \"required\": true\n }\n}\n```\n\n**`mcp`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"mcp\",\n \"mcp\": { \"tool_name\": \"tool_name\", \"expected_result\": null },\n \"required\": true\n }\n}\n```\n\n**`user_input`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"user_input\",\n \"user_input\": { \"prompt\": \"Confirm completion\" },\n \"required\": true\n }\n}\n```\n\n**`comment`:**\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n**Parsing rule:** Only the **last** fenced code block in a step is read;\nit must be valid JSON with a `challenge` key. The block is stripped from\nstored text; the challenge becomes that step's `proof_of_work`.\n\n### Challenge execution semantics\n\n- **`shell`:** Run the command the challenge describes (prefer\n `invocation_display`); honor `workdir` locally; report\n `exit_code`/`stdout`/`stderr`. Exit code 0 = success. See `kairos_begin`\n for silent execution: automatic shell steps should not be narrated to\n the user unless they fail.\n\n### Session working directory (`$KAIROS_WORK_DIR`)\n\nThe MCP server has **no access** to the user's project filesystem. Any\n**engine-managed** session directory under `.local/cache/kairos/<nonce>/`\nis an **agent or CLI convention**: create/remove it in the workspace when\ndocumented, add `.local/` to `.gitignore` if you use it, and export\n`KAIROS_WORK_DIR` for steps that reference it in `workdir` or `args`.\nOptional env `KAIROS_PRESERVE_ON_FAILURE=1` may skip cleanup on failure\nfor post-mortems — document that in your protocol if you rely on it.\n- **`mcp`:** Call the tool; report `result` and `success`.\n- **`user_input`:** Display the prompt to the user; place only their\n reply in `user_input.confirmation`.\n- **`comment`:** Provide text meeting the minimum length; the server\n validates relevance to the step.\n\nFor agent execution rules (what agents must do per type), see the\n`kairos_begin` and `kairos_next` tool descriptions.\n\n---\n\n## MUST ALWAYS\n\n**Document structure:**\n\n- Use H1 (`# Title`) for protocol chain labels.\n- Use H2 (`## Step N`) for individual steps.\n- Place challenge markers **within** the H2 section they apply to.\n\n**Challenge placement:**\n\n- Place the challenge at the **end** of an H2 section as a single\n trailing ` ```json ` block.\n- Only the **last** code block in a step is parsed as the challenge.\n- Ensure the opening \\`\\`\\`json is at **line start** (on its own line,\n no prefix). Blocks with text on the same line (e.g. `Example: \\`\\`\\`json`)\n are not parsed as steps.\n\n**`kairos_mint` usage:**\n\n- Pass `markdown_doc` as a string.\n- Include `llm_model_id` (e.g. `\"minimax/minimax-m2:free\"`).\n- Use `force_update: true` to overwrite existing chains with the same\n label.\n\n**Solution submission:**\n\n- Submit via `kairos_next(uri, solution)`.\n- Solution structure by type:\n - `shell`: `{ type: \"shell\", shell: { exit_code, stdout, stderr,\n duration_seconds } }`\n - `mcp`: `{ type: \"mcp\", mcp: { tool_name, arguments, result,\n success } }`\n - `user_input`: `{ type: \"user_input\", user_input: { confirmation,\n timestamp } }`\n - `comment`: `{ type: \"comment\", comment: { text } }`\n\n---\n\n## MUST NEVER\n\n**Document structure:**\n\n- Mix H1 and H2 in unpredictable ways.\n- Place the challenge JSON block outside the H2 section it ends.\n- Use legacy line-based challenge syntax; use only the trailing JSON\n block.\n\n**Challenge definitions:**\n\n- Use the deprecated `proof_of_work` field in API calls; use `solution`\n instead.\n- Submit solutions that do not match the challenge type.\n\n**`kairos_mint`:**\n\n- Pass `markdown_doc` as an object — always pass as a string.\n- Omit `llm_model_id` — it is required.\n- Store duplicate chains without `force_update: true`.\n\n**Workflow:**\n\n- Confuse `challenge` (output from `kairos_next`) with `solution` (input\n to `kairos_next`).\n- Use the deprecated `proof_of_work` field; use `solution`.\n- Assume step 1 requires a solution submission — step 1 is begun with\n `kairos_begin` only.\n\n---\n\n## Workflow examples\n\n### Example 1: Simple protocol with shell challenges\n\nUse one H1, then one H2 per step. End each step with a ` ```json `\nblock containing `{\"challenge\": {...}}`:\n\n```\n## Step 1: Initialize\nCreate the project structure.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"mkdir -p project/src\",\"timeout_seconds\":10},\"required\":true}}\n```\n```\n\nRepeat for Steps 2 and 3 with their own `shell` challenge blocks.\n\n**Execution flow:**\n\n1. `kairos_search(\"simple setup\")` → returns `must_obey: true` with\n `next_action` containing URI.\n2. `kairos_begin(uri)` → returns step 1 with `challenge` and\n `next_action` with next URI.\n3. `kairos_next(step2_uri, { type: \"shell\", proof_hash: \"...\",\n shell: {...} })` → returns step 2.\n4. Continue through all steps; echo `proof_hash` from each response.\n5. Last `kairos_next` returns `next_action` to call `kairos_attest`.\n Call it to complete the run.\n\n### Example 2: Protocol with comment and user_input challenges\n\nStep 1 ends with a `comment` challenge block; Step 2 with a\n`user_input` block.\n\nStep 1 markdown:\n\n```\n## Step 1: Review\nReview the documentation for accuracy.\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":50},\"required\":true}}\n```\n```\n\nStep 2 markdown:\n\n```\n## Step 2: Confirm\nConfirm review is complete.\n\n```json\n{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"Type 'approved' to confirm\"},\"required\":true}}\n```\n```\n\n### Example 3: Multi-chain document\n\nUse two H1 sections (Protocol A, Protocol B). Each H1 creates a\nseparate chain. Each chain has one or more H2 steps; each step ends with\na ` ```json ` challenge block.\n\n**Result:** Two separate protocol chains are created.\n\n---\n\n## Challenge vs solution nomenclature\n\n- **Challenge** = what `kairos_next` **returns** (what the agent must\n complete).\n- **Solution** = what you **submit** to `kairos_next` (proof you\n completed it).\n\nIn markdown: use a trailing ` ```json ` block with `{\"challenge\": {...}}`\nper step. The API uses `challenge` (output) and `solution` (input).\n\n---\n\n## Validation rules\n\n| Type | Pass condition |\n|------|----------------|\n| `shell` | `exit_code === 0` |\n| `mcp` | `success === true` |\n| `user_input` | Any non-empty `confirmation` |\n| `comment` | `text.length` ≥ `challenge.comment.min_length` |\n\n**Step progression:**\n\n- Step 1: no solution required — call `kairos_begin` only.\n- Steps 2+: solution required — submit matching `solution`.\n- Include `nonce` and `proof_hash` in solution (echo from\n challenge/response).\n- Last step: `kairos_next` directs to `kairos_attest`; call attest to\n finalize.\n\n**Error handling (two-phase retry):**\n\n- Retries 1–3: `must_obey: true` with `error_code` and `next_action`\n for recovery.\n- After 3 retries: `must_obey: false` — choose to fix the step, abort,\n or ask the user.\n- Error responses include `error_code` (e.g. `NONCE_MISMATCH`,\n `TYPE_MISMATCH`) and `retry_count`.\n\n---\n\n## Quick reference\n\n| Operation | Tool | Required fields |\n|-----------|------|-----------------|\n| Mint document | `kairos_mint` | `markdown_doc`, `llm_model_id` |\n| Find protocol | `kairos_search` | `query` |\n| Start protocol | `kairos_begin` | `uri` (from `next_action`) |\n| Continue step | `kairos_next` | `uri` (from `next_action`), `solution` with `nonce` + `proof_hash` |\n| Complete protocol | `kairos_attest` | `uri`, `outcome`, `message` |\n"
|
|
16
16
|
},
|
|
17
17
|
"templates": {
|
|
18
18
|
"kairos-memory": "# {Protocol title}\n\n{One-sentence description of what this protocol does and when to run it.}\n\n## Natural Language Triggers\n\n**Run this protocol when the user says ANY of:**\n\n- \"{trigger phrase 1}\"\n- \"{trigger phrase 2}\"\n- \"{trigger phrase 3}\"\n\n**Trigger verbs** + ({noun1} / {noun2} / {noun3}):\n\n- **{verb1}** / **{verb2}** / **{verb3}**\n\n**Must Never:**\n\n- Trigger on \"{phrase}\" when the user means {different intent}\n- Run without {required precondition}\n\n**Must Always:**\n\n- {Mandatory behaviour 1}\n- {Mandatory behaviour 2}\n\n**Good trigger examples:**\n\n- \"{phrase that activates}\" → run this protocol\n- \"{phrase that activates}\" → run this protocol\n\n**Bad trigger examples:**\n\n- \"{phrase that must not activate}\" → {what to do instead}\n- \"{phrase that must not activate}\" → {what to do instead}\n\n## Step 1: {Step label}\n\n{What the agent must do in this step.}\n\n```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": { \"cmd\": \"{command}\", \"timeout_seconds\": 60 },\n \"required\": true\n }\n}\n```\n\n## Step 2: {Step label}\n\n{What the agent must do in this step.}\n\n```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n## Completion rule\n\nOnly reachable after all prior steps are solved. Show the outputs from\nall prior steps to the user. No additional challenge.\n"
|
|
19
19
|
},
|
|
20
20
|
"tools": {
|
|
21
|
-
"kairos_attest": "Attest protocol completion or failure. Final step of every protocol run.\n\n**Precondition:** `kairos_next` (or `kairos_begin` for a single-step\nprotocol) returned `next_action` directing you to call `kairos_attest`.\nThere are no more steps to solve.\n\n**Input:**\n\n- `uri` — last step URI from the completion response's `next_action`.\n- `outcome` — `\"success\"` or `\"failure\"`.\n- `message` — short summary (1–2 sentences) of how the protocol went.\n\n**Response:** Confirmation that the run is recorded.\n\n**After attestation:** The protocol run is complete. Respond to the\nuser. Do not respond before attestation when `must_obey: true`.\n\n**MUST ALWAYS**\n\n- Call `kairos_attest` as the final action of every protocol run.\n- Report `outcome: \"failure\"` when any step failed or was aborted.\n\n**MUST NEVER**\n\n- Respond to the user before calling `kairos_attest` when `must_obey:\n true`.\n- Skip attestation on error paths — always attest, even on failure.\n",
|
|
22
|
-
"kairos_begin": "Start protocol execution. Loads step 1 and returns its challenge.\nStep 1 never requires a solution submission.\n\n**Precondition (uri path):** You have a URI from `kairos_search` (via a\nchoice's `next_action`), or another trusted source. Do not invent URIs.\n\n**Precondition (key path):** You know the protocol's exact **slug**\n(stored at mint; exported in `kairos_dump` frontmatter when\n`protocol: true`). Use this for deterministic protocol-to-protocol\nrouting without semantic search.\n\n**Input:**\n\n- `uri` (optional) — `kairos://mem/{uuid}` from `kairos_search` or dump.\n If you supply a non-step-1 URI, KAIROS auto-redirects to step 1.\n- `key` (optional) — protocol slug (lowercase, hyphens; exact Qdrant\n match). Omit when using `uri`.\n\nProvide **one** of `uri` or `key`. If both are sent, **`uri` takes\nprecedence** (key is ignored).\n\n**Response:** `current_step` (content + uri), `challenge` (type,\ndescription, nonce, proof_hash), `next_action` with the exact URI for\nthe next call. Always `must_obey: true`.\n\n**AI decision tree:**\n\n- `next_action` mentions `kairos_next`: execute the challenge, then call\n `kairos_next` with the URI from `next_action` and a solution matching\n the challenge type.\n- `next_action` directs you to `kairos_attest`: single-step protocol.\n Call `kairos_attest` with the given URI and outcome/message; run is\n done.\n\n**Execution rules by `challenge.type`:**\n\n- `shell`:
|
|
21
|
+
"kairos_attest": "Attest protocol completion or failure. Final step of every protocol run.\n\n**Precondition:** `kairos_next` (or `kairos_begin` for a single-step\nprotocol) returned `next_action` directing you to call `kairos_attest`.\nThere are no more steps to solve.\n\n**Input:**\n\n- `uri` — last step URI from the completion response's `next_action`.\n- `outcome` — `\"success\"` or `\"failure\"`.\n- `message` — short summary (1–2 sentences) of how the protocol went.\n\n**Response:** Confirmation that the run is recorded.\n\n**After attestation:** The protocol run is complete. Respond to the\nuser. Do not respond before attestation when `must_obey: true`.\n\n**User-facing output rules:**\n\nAfter calling `kairos_attest`, present a **single** summary to the user:\n\n- What the protocol did (1–3 short bullet points).\n- What changed (files, minted resources, tickets, etc.).\n- Any follow-up actions still needed.\n\nDo **not** replay individual step bodies, challenge JSON, shell command lines, or full execution traces — the user needs the **outcome**, not the log.\n\n**Exception:** If the run failed, include the specific error and which step failed so the user can decide next steps.\n\n**MUST ALWAYS**\n\n- Call `kairos_attest` as the final action of every protocol run.\n- Report `outcome: \"failure\"` when any step failed or was aborted.\n\n**MUST NEVER**\n\n- Respond to the user before calling `kairos_attest` when `must_obey:\n true`.\n- Skip attestation on error paths — always attest, even on failure.\n",
|
|
22
|
+
"kairos_begin": "Start protocol execution. Loads step 1 and returns its challenge.\nStep 1 never requires a solution submission.\n\n**Precondition (uri path):** You have a URI from `kairos_search` (via a\nchoice's `next_action`), or another trusted source. Do not invent URIs.\n\n**Precondition (key path):** You know the protocol's exact **slug**\n(stored at mint; exported in `kairos_dump` frontmatter when\n`protocol: true`). Use this for deterministic protocol-to-protocol\nrouting without semantic search.\n\n**Input:**\n\n- `uri` (optional) — `kairos://mem/{uuid}` from `kairos_search` or dump.\n If you supply a non-step-1 URI, KAIROS auto-redirects to step 1.\n- `key` (optional) — protocol slug (lowercase, hyphens; exact Qdrant\n match). Omit when using `uri`.\n\nProvide **one** of `uri` or `key`. If both are sent, **`uri` takes\nprecedence** (key is ignored).\n\n**Response:** `current_step` (content + uri), `challenge` (type,\ndescription, nonce, proof_hash), `next_action` with the exact URI for\nthe next call. Always `must_obey: true`.\n\n**Challenge execution modes:**\n\n- `shell`: **AUTOMATIC.** Run the command (see `challenge.shell.invocation_display` when present), capture output, submit `kairos_next` with a real solution. Do **not** show the command or output to the user unless it fails.\n- `mcp`: **AUTOMATIC.** Call the tool, capture result, submit solution. Do **not** show the tool call to the user unless it fails.\n- `comment`: **AUTOMATIC.** Write the comment, submit solution. Do **not** show the comment text to the user.\n- `user_input`: **REQUIRES USER.** Display `challenge.user_input.prompt` verbatim. Wait for their response. Submit their exact reply. This is the **only** challenge type that pauses for human input.\n\n**Silent execution principle:**\n\nProtocol steps run **silently** from the user's perspective. You **MUST NOT**:\n\n- Narrate what you are about to do before each step.\n- Ask permission to execute automatic challenges (`shell`, `mcp`, `comment`).\n- Show raw step markdown or challenge JSON to the user.\n- Pause between steps unless a `user_input` challenge requires it.\n\nYou **MUST**:\n\n- Execute all automatic steps without user interaction.\n- Display `user_input` prompts verbatim when encountered.\n- Accumulate a concise summary of actions and outcomes.\n- Present that summary **once** after `kairos_attest` (see `kairos_attest` tool description for user-facing output rules).\n\n**AI decision tree:**\n\n- `next_action` mentions `kairos_next`: execute the challenge, then call\n `kairos_next` with the URI from `next_action` and a solution matching\n the challenge type.\n- `next_action` directs you to `kairos_attest`: single-step protocol.\n Call `kairos_attest` with the given URI and outcome/message; run is\n done.\n\n**Execution rules by `challenge.type`:**\n\n- `shell`: Follow `challenge.description` and `challenge.shell`. Prefer the exact argv implied by `invocation_display` when present (includes `interpreter`, `flags`, `args`, `workdir` semantics). Report actual `exit_code`, `stdout`, and `stderr` (do not suppress stderr). Never fabricate. If `interpreter` is set, ensure it exists on PATH (e.g. `which`) before running.\n- `mcp`: Call `challenge.mcp.tool_name`. Report actual result.\n `success` must reflect reality.\n- `user_input`: Display `challenge.user_input.prompt` verbatim to the\n user. Place their exact reply in `user_input.confirmation`. Never\n invent it.\n- `comment`: Write a genuine comment relevant to the step that meets\n `challenge.comment.min_length`.\n\n**Proof hash:** Echo `challenge.proof_hash` as `solution.proof_hash` in\nthe next `kairos_next` call. The server generates all hashes.\n\n**MUST ALWAYS**\n\n- Perform the actual challenge work before submitting the solution.\n- Echo `challenge.nonce` and `challenge.proof_hash` verbatim in the\n next `kairos_next` call.\n\n**MUST NEVER**\n\n- Compute or modify hashes or nonces.\n- Call `kairos_begin` again on error — use the fresh challenge in the\n error response to retry via `kairos_next`.\n\n**Errors (key path):** `INVALID_PROTOCOL_KEY` (bad slug shape),\n`PROTOCOL_KEY_NOT_FOUND` (no step-1 match in searchable spaces),\n`PROTOCOL_KEY_AMBIGUOUS` (same slug in multiple chains/spaces — use\n`uri` or narrow space). HTTP status codes are always in the 4xx/5xx\nrange even if an internal error carries an invalid code.\n",
|
|
23
23
|
"kairos_delete": "Delete one or more memories from KAIROS.\n\n**Precondition:** You have the target memory URI(s). Resolve URIs via\n`kairos_search` and chain navigation before calling.\n\n**Input:**\n\n- `uris` (required, non-empty array) — `kairos://mem/{uuid}` URIs to\n delete.\n\n**Response:** Confirmation of deleted URIs.\n\n**MUST ALWAYS**\n\n- Resolve and verify the target URIs before deleting.\n- Confirm the user's intent to delete before calling when acting on\n user instruction.\n\n**MUST NEVER**\n\n- Delete a URI you have not resolved or verified.\n- Call with an empty `uris` array.\n",
|
|
24
24
|
"kairos_dump": "Read-only inspection of a memory or full protocol. Returns\n`markdown_doc` for use with `kairos_update` or `kairos_mint`. No run\nstate, no nonce.\n\n**Precondition:** You have a memory URI.\n\n**Input:**\n\n- `uri` — `kairos://mem/{uuid}`.\n- `protocol` (optional, default `false`) — when `true`, returns the\n full chain as one markdown document; otherwise returns the single\n step's content.\n\n**Output:**\n\n- Default mode: `markdown_doc` (string), and optionally `uri`, `label`,\n `position`, `challenge`.\n- Protocol mode: `markdown_doc` (string) begins with YAML **frontmatter**\n (`slug:` and `version:` when present), then `#` chain title and steps;\n response also includes `slug`, `uri` (chain head), `label`,\n `step_count`, and `protocol_version` when set.\n\n**Round-trip edit flow (single step):**\n\n1. `kairos_dump(uri)` → receive `markdown_doc`.\n2. Edit `markdown_doc`.\n3. `kairos_update({ uris: [uri], markdown_doc: [edited] })`.\n\n**Round-trip edit flow (full protocol):**\n\n1. `kairos_dump(uri, { protocol: true })` → receive full `markdown_doc`.\n2. Edit.\n3. `kairos_mint({ markdown_doc, llm_model_id, force_update: true })`.\n\n**MUST NEVER**\n\n- Use `kairos_dump` to bypass execution; use it only for inspection and\n round-trip edit flows.\n",
|
|
25
|
-
"kairos_mint": "Store a markdown document as a KAIROS protocol chain. Each H1 defines\na chain; each H2 defines a step.\n\n**Precondition:** You have a complete markdown document with H1 title,\nH2 steps, and a trailing ` ```json ` challenge block per verifiable step.\n\n**Recommended:** For guided protocol creation, call `kairos_begin` with\n`kairos://mem/00000000-0000-0000-0000-000000002001`. Direct minting\nrequires: `## Natural Language Triggers` (first H2), `## Completion Rule`\n(last H2), and at least one challenge block.\n\n**Optional YAML frontmatter** (before the H1) can set:\n\n- `slug:` — exact routing key for `kairos_begin` with `key` (lowercase,\n letters, digits, hyphens only). Must be **unique per space**; mint\n fails with `DUPLICATE_SLUG` if another protocol already uses it.\n- `version:` — same as `protocol_version` below.\n\nIf `slug` is omitted, it is **auto-generated** from the H1 title\n(lowercase, hyphenated). If that collides with another protocol's slug,\nthe server appends `-2`, `-3`, … until unique.\n\n**Input:**\n\n- `markdown_doc` (string) — the markdown protocol document.\n- `llm_model_id` (required) — e.g. `\"minimax/minimax-m2:free\"`.\n- `force_update` (optional, default `false`) — set `true` to overwrite\n an existing chain with the same label.\n- `protocol_version` (optional) — e.g. `\"1.0.0\"`. Overrides or supplies\n the version when the document has no YAML frontmatter; otherwise\n version is parsed from frontmatter. Stored and exposed in\n `kairos_search` choices for agent comparison.\n\n**Challenge block format:** Place a single trailing ` ```json ` block at\nthe end of each H2 step. The object must have a `challenge` key. Only\nthe last code block in a step is parsed as the challenge. **The opening\n\\`\\`\\`json must be at line start** (on its own line with no text before\nit). Blocks with text on the same line (e.g. `Example: \\`\\`\\`json`) are\nnot parsed as steps.\n\nAdd a challenge to every step that can be verified. Omit challenges only\nfor purely informational steps where no verification is possible.\n\n**Challenge examples (one per type):**\n\n`shell` — run a command
|
|
26
|
-
"kairos_next": "Submit a solution and advance to the next step. Use for every step\nafter step 1.\n\n**Precondition:** You have completed the current step's challenge. You\nhave the URI from the previous response's `next_action`.\n\n**Input:**\n\n- `uri` — current step URI from `next_action` of the previous response.\n Do not use for step 1 — use `kairos_begin` for step 1.\n- `solution` — proof matching `challenge.type`:\n - `shell`: `{ type: \"shell\", shell: { exit_code, stdout?, stderr?,\n duration_seconds? } }` — `exit_code: 0` = success.\n - `mcp`: `{ type: \"mcp\", mcp: { tool_name, result, success,\n arguments? } }` — `success` must be `true`.\n - `user_input`: `{ type: \"user_input\", user_input: { confirmation,\n timestamp? } }`.\n - `comment`: `{ type: \"comment\", comment: { text } }` — `text.length`\n must meet `challenge.comment.min_length`.\n- `solution.nonce` — echo from `challenge.nonce` when present.\n- `solution.proof_hash` — echo `challenge.proof_hash` for step 1; for\n steps 2+ echo the `proof_hash` from the previous `kairos_next`\n response. The server generates all hashes.\n\n**Execution rules by `challenge.type`:**\n\n- `shell`:
|
|
25
|
+
"kairos_mint": "Store a markdown document as a KAIROS protocol chain. Each H1 defines\na chain; each H2 defines a step.\n\n**Precondition:** You have a complete markdown document with H1 title,\nH2 steps, and a trailing ` ```json ` challenge block per verifiable step.\n\n**Recommended:** For guided protocol creation, call `kairos_begin` with\n`kairos://mem/00000000-0000-0000-0000-000000002001`. Direct minting\nrequires: `## Natural Language Triggers` (first H2), `## Completion Rule`\n(last H2), and at least one challenge block.\n\n**Optional YAML frontmatter** (before the H1) can set:\n\n- `slug:` — exact routing key for `kairos_begin` with `key` (lowercase,\n letters, digits, hyphens only). Must be **unique per space**; mint\n fails with `DUPLICATE_SLUG` if another protocol already uses it.\n- `version:` — same as `protocol_version` below.\n\nIf `slug` is omitted, it is **auto-generated** from the H1 title\n(lowercase, hyphenated). If that collides with another protocol's slug,\nthe server appends `-2`, `-3`, … until unique.\n\n**Input:**\n\n- `markdown_doc` (string) — the markdown protocol document.\n- `llm_model_id` (required) — e.g. `\"minimax/minimax-m2:free\"`.\n- `force_update` (optional, default `false`) — set `true` to overwrite\n an existing chain with the same label.\n- `protocol_version` (optional) — e.g. `\"1.0.0\"`. Overrides or supplies\n the version when the document has no YAML frontmatter; otherwise\n version is parsed from frontmatter. Stored and exposed in\n `kairos_search` choices for agent comparison.\n\n**Challenge block format:** Place a single trailing ` ```json ` block at\nthe end of each H2 step. The object must have a `challenge` key. Only\nthe last code block in a step is parsed as the challenge. **The opening\n\\`\\`\\`json must be at line start** (on its own line with no text before\nit). Blocks with text on the same line (e.g. `Example: \\`\\`\\`json`) are\nnot parsed as steps.\n\nAdd a challenge to every step that can be verified. Omit challenges only\nfor purely informational steps where no verification is possible.\n\n**Challenge examples (one per type):**\n\n`shell` — run a command (executor-side). Required: `cmd`, `timeout_seconds`.\nOptional: `interpreter`, `flags`, `args`, `workdir` — see\n`building-kairos-workflows` and `kairos_begin` for argv rules and silent\nexecution.\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"shell\",\n \"shell\": { \"cmd\": \"npm test\", \"timeout_seconds\": 60 },\n \"required\": true\n }\n}\n```\n\n`comment` — verification text:\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"comment\",\n \"comment\": { \"min_length\": 50 },\n \"required\": true\n }\n}\n```\n\n`user_input` — human confirmation:\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"user_input\",\n \"user_input\": { \"prompt\": \"Approve deployment?\" },\n \"required\": true\n }\n}\n```\n\n`mcp` — call an MCP tool:\n\nExample: ```json\n{\n \"challenge\": {\n \"type\": \"mcp\",\n \"mcp\": { \"tool_name\": \"kairos_mint\" },\n \"required\": true\n }\n}\n```\n\n**Response:** Chain head URI(s). Find the minted protocol via\n`kairos_search` with a query matching the document content.\n\n**MUST ALWAYS**\n\n- Pass `markdown_doc` as a string.\n- Include `llm_model_id`.\n- Include a `## Natural Language Triggers` section as the first H2 and a\n `## Completion Rule` section as the last H2.\n- Use `force_update: true` when overwriting an existing chain with the\n same label.\n\n**MUST NEVER**\n\n- Pass `markdown_doc` as an object.\n- Omit `llm_model_id`.\n- Store duplicate chains without `force_update: true`.\n",
|
|
26
|
+
"kairos_next": "Submit a solution and advance to the next step. Use for every step\nafter step 1.\n\n**Precondition:** You have completed the current step's challenge. You\nhave the URI from the previous response's `next_action`.\n\n**Input:**\n\n- `uri` — current step URI from `next_action` of the previous response.\n Do not use for step 1 — use `kairos_begin` for step 1.\n- `solution` — proof matching `challenge.type`:\n - `shell`: `{ type: \"shell\", shell: { exit_code, stdout?, stderr?,\n duration_seconds? } }` — `exit_code: 0` = success.\n - `mcp`: `{ type: \"mcp\", mcp: { tool_name, result, success,\n arguments? } }` — `success` must be `true`.\n - `user_input`: `{ type: \"user_input\", user_input: { confirmation,\n timestamp? } }`.\n - `comment`: `{ type: \"comment\", comment: { text } }` — `text.length`\n must meet `challenge.comment.min_length`.\n- `solution.nonce` — echo from `challenge.nonce` when present.\n- `solution.proof_hash` — echo `challenge.proof_hash` for step 1; for\n steps 2+ echo the `proof_hash` from the previous `kairos_next`\n response. The server generates all hashes.\n\n**Challenge execution modes:** Same as `kairos_begin`: `shell`, `mcp`, and `comment` are **AUTOMATIC** (run and submit without asking the user); `user_input` is the **only** type that requires showing a prompt and waiting for a human reply. See `kairos_begin` for the **silent execution principle**.\n\n**Execution rules by `challenge.type`:**\n\n- `shell`: Same as `kairos_begin` — use `invocation_display` / `challenge.shell` / `description`; capture `stdout` and `stderr`; never fabricate.\n- `mcp`: Call `challenge.mcp.tool_name`. Report actual result.\n `success` must reflect reality.\n- `user_input`: Display `challenge.user_input.prompt` verbatim to the\n user. Place their exact reply in `user_input.confirmation`. Never\n invent it.\n- `comment`: Write a genuine comment relevant to the step that meets\n `challenge.comment.min_length`.\n\n**Response:** `current_step`, `challenge` (for next step), `next_action`\n(next tool call with embedded URI), `proof_hash` (use as\n`solution.proof_hash` for the next step).\n\n**AI decision tree:**\n\n- `must_obey: true` — follow `next_action` (success or recoverable\n error, retries 1–3).\n- `must_obey: false` — use judgment (max retries exceeded). Options in\n `next_action`: fix the step via `kairos_update`, abort via\n `kairos_attest` with `outcome: \"failure\"`, or ask the user.\n- `next_action` directs you to `kairos_attest` — call attest with the\n given URI and outcome/message; protocol run is done, then respond to\n the user.\n\n**Error responses** include `error_code` (e.g. `NONCE_MISMATCH`,\n`TYPE_MISMATCH`, `MAX_RETRIES_EXCEEDED`) and `retry_count`. A fresh\n`challenge` with a new nonce is included for retry.\n\n**MUST ALWAYS**\n\n- Perform the actual challenge work before submitting.\n- Use the URI from the previous `next_action`, not a stored or invented\n URI.\n- Echo `nonce` and `proof_hash` verbatim from the correct source.\n\n**MUST NEVER**\n\n- Fabricate shell output, MCP results, or user confirmations.\n- Compute or modify hashes or nonces.\n- Re-call `kairos_begin` on error; retry using the error response's\n fresh challenge.\n",
|
|
27
27
|
"kairos_search": "Find and start executable workflows matching the user's intent.\n\n**PROACTIVE USE:** Call this tool whenever the user's message describes\nan action, task, workflow, or procedure — even if they do not mention\nKAIROS, protocols, or tools. The user's natural language IS the query.\n\n**Input:**\n\n- `query` — the user's message or a concise intent phrase (3–8 words\n preferred, but natural language accepted). Stay faithful to the\n user's intent; add specificity, do not substitute your own\n interpretation. Expand slash-commands or shorthand (e.g. `/ai-docs` →\n `write ai instructions zero-drift template`).\n- `max_choices` (optional) — maximum number of match choices to return.\n Omit for server default. Use a higher value for broad or vague\n queries when the best match may not be in the top few.\n\n**Response:** Always `must_obey: true`. Contains `choices` array (each\nwith `uri`, `label`, `chain_label`, `score`, `role`, `tags`,\n`next_action`, and optional `protocol_version`), `message`, and a\nglobal `next_action`. For match choices, `protocol_version` is the\nstored protocol version (e.g. semver); compare with skill-bundled\nprotocol to decide if re-mint is needed.\n\n**Choice roles:**\n\n- `role: \"match\"` — search result with `score` (0.0–1.0). Higher score\n = closer match. That choice's `next_action` directs you to call\n `kairos_begin` with its URI.\n- `role: \"refine\"` — step-by-step help to build a more specific query. That\n choice's `next_action` directs you to call `kairos_begin` with the\n refine-help protocol URI.\n- `role: \"create\"` — create a new protocol (`score: null`). That\n choice's `next_action` directs you to call `kairos_begin` with the\n creation protocol URI.\n\n**Ordering:** Match choices first (top N), then refine (if present),\nthen create (if present). Refine and create are not part of the search\nlimit.\n\n**AI decision tree:** `must_obey: true` — pick one choice and follow\n**that choice's `next_action`**. The global `next_action` says: \"Pick\none choice and follow that choice's next_action.\"\n\nWhen results are weak (no scores above 0.5), pick the refine choice and\nrun that protocol for step-by-step help improving the query.\n\n**MUST ALWAYS**\n\n- Follow the chosen choice's `next_action`, not the global `next_action`.\n- Call `kairos_begin` with the chosen URI as the next step.\n\n**MUST NEVER**\n\n- Reuse a vague query that already returned no strong match.\n- Run `kairos_begin` with a URI not returned by this response.\n",
|
|
28
28
|
"kairos_spaces": "List the agent's available spaces with human-readable names and chain\ncounts.\n\n**Precondition:** None.\n\n**Input:**\n\n- `include_chain_titles` (optional, default `false`) — when `true`,\n each space includes a `chains` array with `chain_id`, `title`, and\n `step_count`.\n\n**Output:** `spaces` array. Each item has:\n\n- `name` — human-readable: `\"Personal\"`, `\"Group: <ref>\"`, or\n `\"Kairos app\"`.\n- `chain_count` — number of protocol chains in this space.\n- `chains` (optional) — array of `{ chain_id, title, step_count }` when\n `include_chain_titles: true`.\n\nSpaces include the agent's personal space, any group spaces, and the\nKairos app space (read-only protocols).\n\n**MUST ALWAYS**\n\n- Use space names (not raw IDs) in tool parameters such as `kairos_mint`.\n\n**MUST NEVER**\n\n- Pass raw space IDs in tool parameters; the backend resolves names to\n IDs.\n",
|
|
29
29
|
"kairos_update": "Update one or more existing memories in KAIROS using markdown or\nfield-level updates.\n\n**Precondition:** You have the target memory URI(s). Resolve URIs via\n`kairos_search` followed by chain navigation, or use a URI already in\nscope.\n\n**Input:**\n\n- `uris` (required) — array of `kairos://mem/{uuid}` URIs to update.\n- `markdown_doc` (array of markdown strings, one per URI) — replaces\n the full content of each targeted memory.\n- `updates` (field-level updates) — use when replacing specific fields\n instead of the full document.\n\nProvide either `markdown_doc` or `updates`, not both.\n\n**Typical round-trip edit flow:**\n\n1. Call `kairos_dump(uri)` to retrieve the current `markdown_doc`.\n2. Edit the markdown.\n3. Call `kairos_update({ uris: [uri], markdown_doc: [edited_markdown] })`.\n\n**Response:** Updated memory URI(s) and confirmation.\n\n**MUST ALWAYS**\n\n- Resolve the target URI before calling `kairos_update`.\n- Provide one `markdown_doc` entry per URI in `uris` when using\n `markdown_doc` mode.\n\n**MUST NEVER**\n\n- Update a URI you have not resolved or verified.\n- Mix `markdown_doc` and `updates` in the same call.\n"
|
|
30
30
|
},
|
|
31
|
-
"mem": {}
|
|
31
|
+
"mem": {},
|
|
32
|
+
"meta": {
|
|
33
|
+
"create-new-protocol": "---\nversion: \"3.4.0\"\nslug: create-new-protocol\ntitle: Create New KAIROS Protocol Chain\n---\n\n# Create New KAIROS Protocol Chain\n\nGuide an AI agent through authoring a new executable protocol chain in KAIROS.\nThis protocol is offered when kairos_search finds no match. Review and publishing continue in Chain 2 (`create-new-protocol-review`).\n\n## Natural Language Triggers\n\n**Run this protocol when the user says ANY of:**\n\n- \"create a new KAIROS protocol\" / \"create new protocol chain\"\n- \"mint a workflow\" / \"create a new workflow\"\n- \"create new protocol\" (when kairos_search found no match and user confirms)\n\n**Trigger pattern:** **create** / **mint** + (protocol / workflow / chain) [ + (new / KAIROS) ].\n\n**Must Never:**\n- Run when the user only asked to run an existing protocol (use search → begin → next → attest).\n- Trigger when a strong match already exists from kairos_search.\n\n**Must Always:**\n- Confirm with the user that they want to create a new protocol when search found no match.\n- Include Natural Language Triggers as the first H2 and Completion Rule as the last H2.\n- Apply DRY: no duplicated H2s, no boilerplate sections — fold shared content into steps or extract to a reference.\n- Enforce 350-line max per file. If content exceeds this, split into linked chains or extract a type extension / reference.\n- Load `challenge-type-guide` policy via `kairos_begin(key: \"challenge-type-guide\")` when choosing challenge types for steps. `comment` is the last resort — use `shell` or `mcp` whenever the step produces an observable artifact.\n\n**Good trigger examples:**\n- \"Create a new KAIROS protocol for code review\" → run this protocol\n- \"No match found; I want to create a new protocol\" → run this protocol\n\n**Bad trigger examples:**\n- \"Run the standardize project protocol\" → use search/begin, not this\n- \"Search for deployment protocol\" → use kairos_search, not this\n\n---\n\n## Prerequisites\n\nThis protocol requires context from the triggering search:\n\n- `{search_query}` — the original user query that yielded no match\n- `{search_results}` — kairos_search results (empty or weak matches)\n- `{trigger_source}` — `user-explicit` (user asked to create) or `agent-offered` (search returned no match)\n\n**Work directory:** `$KAIROS_WORK_DIR` is provided by the engine (created at `kairos_begin`, cleaned at `kairos_attest`). All draft files go here.\n\n**Security:** Do NOT write credentials, tokens, or secrets into draft files. Use placeholder references (`${SECRET_NAME}`) for sensitive values.\n\n---\n\n## Confirm Intent [SUBAGENT]\n\nGate applies only when the **agent** decides to offer protocol creation (kairos_search returned no strong match). Skip when the **user** explicitly requested creation (trigger phrase matched).\n\n**Input:** `{search_query}`, `{search_results}`, `{trigger_source}`.\n\n**Actions:**\n1. **If `{trigger_source}` = user-explicit:** Set `{intent}` = confirmed. Skip to next step.\n2. **If `{trigger_source}` = agent-offered:**\n - Present the search results (or lack thereof) to the user.\n - Ask: \"No existing protocol matched your query. Create a new one, or refine your search?\"\n - Wait for explicit confirmation before proceeding.\n\n**Output:** `{intent}` = confirmed | refined-search | cancelled, plus any user clarifications on scope.\n\n```json\n{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"Confirm you want to create a new protocol chain (auto-confirmed when user explicitly requested creation)\"},\"required\":true}}\n```\n\n## Gather Requirements [SUBAGENT]\n\nCollect all inputs needed to draft the protocol. Write the requirements summary to `$KAIROS_WORK_DIR/requirements.md`.\n\n**Input:** `{search_query}`, `{intent}` = confirmed, `$KAIROS_WORK_DIR`, any user clarifications on scope.\n\n**Actions:**\n\n1. **Determine the pattern:**\n\n| Signal | Pattern |\n|---|---|\n| One workflow, no variants | **Standalone** — one protocol, all steps inline |\n| Multiple issue types / output formats / media | **Router + Extensions** — router classifies, routes via `kairos_search` |\n| Domain has a decision tree (which type? which format?) | **Router + Extensions** |\n| Reference material needed by steps | Extract to a separate file, not a protocol |\n\nReal examples: Compose (writing router → 5 extensions), BNX/BIB (Jira routers → type-specific creation protocols).\n\n2. **Collect per protocol:**\n - **Title**: clear, descriptive (becomes H1)\n - **Steps**: what the protocol does (each becomes H2 with a challenge)\n - **Challenge type per step**: pick using the decision tree from `kairos_begin(key: \"challenge-type-guide\")` — `shell` or `mcp` first, `comment` only for pure reasoning\n - **Domain reference**: guides/docs the protocol should load?\n - **Existing protocols**: `kairos_search` for related — reuse, compose, or extract shared content?\n - **DRY check**: what content would be duplicated across extensions? Extract to a shared reference or the router body.\n - **Size check**: will any single file exceed 350 lines? If yes, split into chains or extract a reference now — do not plan to \"trim later\".\n\n3. **If Router pattern:**\n - What are the variants? (each becomes an extension protocol)\n - What decision questions classify the variant?\n - What types are forbidden?\n\n4. **Write requirements to file:** Summarize all gathered requirements as structured markdown and write to `$KAIROS_WORK_DIR/requirements.md`.\n\n**Output:** `$KAIROS_WORK_DIR/requirements.md` containing: pattern (standalone/router), title(s), step list with challenge types, slug(s), domain references, DRY assessment, size estimate.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"test -f \\\"$KAIROS_WORK_DIR/requirements.md\\\" && wc -l < \\\"$KAIROS_WORK_DIR/requirements.md\\\" | awk '$1 >= 5'\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## Author Protocol Structure [SUBAGENT]\n\nWrite the protocol markdown — content, flow, step definitions, NLT, Completion Rule — but leave challenge blocks empty. This step is pure protocol design, not verification engineering.\n\n**Input:** `$KAIROS_WORK_DIR/requirements.md`.\n\n**Actions:**\n\n1. **Apply protocol structure rules:**\n - H1: protocol title (one H1 = one chain)\n - First H2: Natural Language Triggers\n - Middle H2s: one per step, with a placeholder `<!-- challenge -->` where the challenge block will go\n - Last H2: Completion Rule\n\n2. **Apply Natural Language Triggers structure (required, exact order):**\n - Trigger phrases — 3–6 quoted phrases\n - Trigger pattern — verb + noun formula\n - Must Never — 1–3 cases (imperative, no \"should\")\n - Must Always — 1–3 mandatory behaviours\n - Good trigger examples — 2–3 with `→ run this protocol`\n - Bad trigger examples — 2–3 with `→ use X instead`\n\n3. **Apply DRY — Don't Repeat Yourself:**\n - Every piece of knowledge lives in exactly one place.\n - Boilerplate belongs **inside the step that needs it** — one sentence, not a section.\n - If two protocols share >50% body, extract shared logic into a base protocol or reference.\n - Every H2 earns its place. Never duplicate an H2 heading — KAIROS treats each H2 as a step.\n\n4. **Enforce 350-line maximum per file:**\n - Over 350 → split via `mcp` challenge with `kairos_begin(key:...)` or extract to reference.\n - Router protocols: ~50–80 lines. Extension protocols: 100–200 lines.\n\n5. **Apply slug convention:**\n - Families: hierarchical. Router slug = prefix. Children expand by one segment.\n - Standalone: action-oriented. Bundle directory is the namespace — slug does not repeat it.\n\n6. **Apply generic-first principle:**\n - Generic chains first; they stand alone with zero extensions.\n - Extensions define only the delta. New type = one new file.\n\n7. **Make every step SUBAGENT-ELIGIBLE:**\n - `[SUBAGENT]` tag on each H2 step title.\n - Explicit `**Input:**`, numbered `**Actions:**`, and `**Output:**` sections.\n - Enough context that a subagent with no prior conversation can execute the step.\n\n8. **If Router pattern:** Draft the router AND each extension as separate markdown files.\n - Classify step: decision tree table, forbidden types, common misclassifications.\n - Route step: `kairos_begin(key: \"slug\")` per type, fallback.\n\n9. **Write draft to file:** Write the protocol markdown to `$KAIROS_WORK_DIR/draft-protocol.md`. Every middle H2 has a `<!-- challenge -->` placeholder where the verification block will be added in the next step.\n\n**Output:** `$KAIROS_WORK_DIR/draft-protocol.md` with complete structure but no challenge blocks.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"D=\\\"$KAIROS_WORK_DIR/draft-protocol.md\\\" && test -f \\\"$D\\\" && grep -c '^## ' \\\"$D\\\" | awk '$1 >= 3' && wc -l < \\\"$D\\\" | awk '$1 <= 350' && grep -q '^## Natural Language Triggers' \\\"$D\\\" && grep -q '^## Completion Rule' \\\"$D\\\"\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## Author Challenge Blocks [SUBAGENT]\n\nReplace every `<!-- challenge -->` placeholder in the draft with a verifiable challenge block by running the challenge-type-guide protocol.\n\n**Input:** `$KAIROS_WORK_DIR/draft-protocol.md` (from previous step).\n\n**Actions:**\n\n1. **Run challenge type guide:** `kairos_begin(key: \"challenge-type-guide\")` — execute the full protocol to internalize decision tree, formats, interpreter rules, and anti-patterns.\n\n2. **Apply to each H2 step:** For every `<!-- challenge -->` placeholder, read the step's Actions and Output, apply the decision tree, select the challenge type and interpreter, write the JSON block in place.\n\n3. **Favour creativity over formality:** Look for non-obvious verification opportunities — a step that \"analyses\" might produce a file (verify line count), a step that \"selects\" might set a variable (verify with `test -n`). The best challenges prove work was done.\n\n4. **Write challenge summary:** Append `$KAIROS_WORK_DIR/challenge-summary.md` listing each step, the challenge type chosen, the interpreter (if shell), and a one-line rationale.\n\n5. **Overwrite draft:** Save the fully challenged version to `$KAIROS_WORK_DIR/draft-protocol.md`.\n\n**Output:** Updated `$KAIROS_WORK_DIR/draft-protocol.md` (no placeholders remain, all JSON valid) and `$KAIROS_WORK_DIR/challenge-summary.md`.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"D=\\\"$KAIROS_WORK_DIR/draft-protocol.md\\\" && S=\\\"$KAIROS_WORK_DIR/challenge-summary.md\\\" && test -f \\\"$D\\\" && test -f \\\"$S\\\" && ! grep -q '<!-- challenge -->' \\\"$D\\\" && perl -MJSON -0777 -ne '@b=/```json\\\\s*\\\\n(\\\\{.*?\\\\})\\\\s*\\\\n```/gs; die \\\"No challenge blocks\\\" unless @b; eval{decode_json($_)} or die \\\"Bad JSON: $@\\\" for @b; print scalar(@b).\\\" valid challenge blocks\\\\n\\\"' \\\"$D\\\"\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## Chain to Review [SUBAGENT]\n\nHand off the drafted protocol to Chain 2 for format review, stranger review, user approval, and minting.\n\n**Input:** `$KAIROS_WORK_DIR` (containing `requirements.md` and `draft-protocol.md`).\n\n**Actions:**\n1. Verify both files exist in `$KAIROS_WORK_DIR`.\n2. Call `kairos_begin(key: \"create-new-protocol-review\")` to continue in Chain 2.\n\n**Output:** Chain 2 execution begins with `$KAIROS_WORK_DIR` available in the shell session.\n\n```json\n{\"challenge\":{\"type\":\"mcp\",\"mcp\":{\"tool_name\":\"kairos_begin\",\"arguments\":{\"key\":\"create-new-protocol-review\"}},\"required\":true}}\n```\n\n## Completion Rule\n\nOnly reachable after all prior steps are solved.\n\nChain 1 is complete when:\n1. User intent confirmed (or auto-confirmed from explicit trigger).\n2. Requirements written to `$KAIROS_WORK_DIR/requirements.md` (≥5 lines).\n3. Protocol structure drafted to `$KAIROS_WORK_DIR/draft-protocol.md` (≥3 H2 steps, ≤350 lines, NLT + Completion Rule present, `<!-- challenge -->` placeholders).\n4. All `<!-- challenge -->` placeholders replaced with valid challenge JSON blocks.\n5. Chain 2 (`create-new-protocol-review`) invoked via `kairos_begin`.\n\nExecution continues in Chain 2 for review, approval, and minting. `$KAIROS_WORK_DIR` is cleaned up by the engine at `kairos_attest`.\n",
|
|
34
|
+
"refine-search": "---\nversion: \"3.4.0\"\nslug: refine-search\ntitle: Get help refining your search\n---\n\n# Get help refining your search\n\n**You are an AI agent.** You ran `kairos_search` and got no solid match (or only weak/ambiguous ones). This protocol helps you turn the user's vague request into a better query so the next `kairos_search` can find the right protocol.\n\n## Natural Language Triggers\n\n**Run this protocol when:**\n\n- `kairos_search` returned no match, or only choices with low score (e.g. all < 0.5).\n- The response included a **refine** (or equivalent) choice directing you to improve the query.\n\n**Trigger pattern:** After **kairos_search** when result is no strong match / refine suggested.\n\n**Must Never:**\n\n- Run when a strong match (score >= 0.5) already exists — use that choice and `kairos_begin` instead.\n- Run when the user has not yet asked for anything (no prior search context).\n- Loop more than once per user request — if two searches fail, the protocol likely does not exist yet.\n\n**Must Always:**\n\n- Run at most once, then either begin the matched protocol, offer to create a new one, or ask the user to clarify.\n\n**Good trigger examples:**\n\n- Search returned only \"refine\" / weak matches → run this protocol\n- \"No protocol matched 'do the thing'\" → run this protocol\n\n**Bad trigger examples:**\n\n- Search returned a strong match → use that match, not this protocol\n- User asked \"what protocols exist?\" → use search/list, not this protocol\n\n## Analyse Intent [SUBAGENT]\n\nExtract what the user actually wants from their original message.\n\n**Input:** User's original message and the failed `kairos_search` results.\n\n**Actions:**\n\n1. Identify **Goal** — what outcome does the user want? (e.g. \"run tests\", \"write docs\", \"create a Jira ticket\")\n2. Identify **Context** — any project, tool, domain, or proper noun mentioned.\n3. Identify **Gaps** — what is missing or ambiguous? (e.g. \"which repo?\", \"which doc type?\", \"which project key?\")\n4. If the request was a slash-command or shorthand (e.g. \"/ai-docs\"), expand it to a concrete description.\n\n**Output:** Analysis with goal, context, and gaps (minimum 50 characters).\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":50},\"required\":true}}\n```\n\n## Refine and Re-search [SUBAGENT]\n\nConstruct and execute a better `kairos_search` query based on the intent analysis.\n\n**Input:** Goal, context, and gaps from previous step.\n\n**Actions:**\n\n1. Build a query of 3–8 specific words (nouns and verbs, no filler). Include domain/tool names if known.\n2. Do **not** reuse the user's exact vague phrase — that already failed.\n3. Call `kairos_search` with the refined query.\n4. Evaluate results:\n - **Strong match (score >= 0.5):** Pick that choice and call `kairos_begin` with its URI.\n - **Weak matches only:** Ask the user to clarify, or pick the \"create\" choice to build a new protocol.\n\n**Output:** Either a `kairos_begin` call for the matched protocol, or a clear message to the user explaining why no match was found and what to do next.\n\n```json\n{\"challenge\":{\"type\":\"mcp\",\"mcp\":{\"tool_name\":\"kairos_search\"},\"required\":true}}\n```\n\n## Completion Rule\n\nOnly reachable after all prior steps are solved.\n\nThis protocol is complete when:\n1. User intent analysed (goal + context + gaps, >= 50 characters).\n2. Refined `kairos_search` executed with an improved query.\n3. One of: matched protocol begun via `kairos_begin`, new protocol creation offered, or user asked to clarify.\n",
|
|
35
|
+
"create-new-protocol-review": "---\nversion: \"3.4.0\"\nslug: create-new-protocol-review\ntitle: Review and Publish New KAIROS Protocol\n---\n\n# Review and Publish New KAIROS Protocol\n\nValidate a drafted KAIROS protocol through format review, stranger review, user approval, and mint. Invoked by Chain 1 (`create-new-protocol`) or directly to re-review an existing draft.\n\n## Natural Language Triggers\n\n**Typically invoked by:** Chain 1's chain link step via `kairos_begin(key: \"create-new-protocol-review\")`.\n\n**Can be invoked directly when user says:**\n\n- \"review my protocol draft\" / \"validate this protocol\"\n- \"re-run format review on my draft\"\n- \"mint my protocol\" (when a draft already exists)\n\n**Trigger pattern:** **review** / **validate** / **mint** + (protocol / draft).\n\n**Must Never:**\n- Run without `$KAIROS_WORK_DIR` set and containing `draft-protocol.md`.\n- Skip format or stranger review steps.\n\n**Must Always:**\n- Verify `$KAIROS_WORK_DIR` and draft file exist before proceeding.\n- Require both reviews to pass before presenting to user.\n- Freeze the draft checksum after reviews pass and verify it before minting.\n- Clean up `$KAIROS_WORK_DIR` after minting (or on cancellation).\n\n**Good trigger examples:**\n- Chained from `create-new-protocol` → run this protocol\n- \"Review and mint my protocol draft\" → run this protocol\n\n**Bad trigger examples:**\n- \"Create a new protocol\" → use `create-new-protocol`, not this\n- \"Search for a protocol\" → use `kairos_search`, not this\n\n---\n\n## Prerequisites\n\nThis protocol requires `$KAIROS_WORK_DIR` from Chain 1 (engine-provided, persists across chained protocols):\n\n- `$KAIROS_WORK_DIR/draft-protocol.md` — the drafted protocol file\n- `$KAIROS_WORK_DIR/requirements.md` — requirements summary (optional, for context)\n\n**If invoked directly** (no Chain 1), the engine creates `$KAIROS_WORK_DIR` at `kairos_begin`. Copy the draft file there before proceeding.\n\n**Security:** Do NOT write credentials, tokens, or secrets into any file in `$KAIROS_WORK_DIR`.\n\n---\n\n## Format Review [SUBAGENT]\n\nDelegate format verification to a subagent. The subagent writes its verdict to `$KAIROS_WORK_DIR/format-review.md`.\n\n**Input:** `$KAIROS_WORK_DIR/draft-protocol.md`.\n\n**Subagent task:**\n\n1. Read `$KAIROS_WORK_DIR/draft-protocol.md`.\n2. Verify protocol structure compliance:\n - H1 present (exactly one)\n - First H2 is Natural Language Triggers (with all 6 subsections: trigger phrases, trigger pattern, Must Never, Must Always, good examples, bad examples)\n - Last H2 is Completion Rule\n - Every middle H2 has a challenge block\n - No duplicate H2 headings\n3. Verify subagent eligibility per step:\n - Every H2 step has `[SUBAGENT]` tag\n - Every step has explicit `**Input:**`, `**Actions:**`, `**Output:**`\n - Actions are numbered and imperative\n4. Verify challenge type selection (per `kairos_begin(key: \"challenge-type-guide\")`):\n - No `comment` challenges on steps that produce files, call tools, or check system state\n - `shell` challenges use compound `&&` chains (not `;`)\n - `shell` challenges include `timeout_seconds`\n5. Verify interpreter selection:\n - Flag bash challenges containing `while read`, `grep | awk`, or escaped quotes deeper than one level — suggest Perl rewrite\n - Multi-line regex validation MUST use `perl -0777` (not bash `grep`)\n - JSON block validation MUST use `perl -MJSON` or `python3 -c 'import json'` (not bash pattern matching)\n - Simple file tests (`test -f`, `which`, `git status`) stay bash\n6. Verify DRY compliance:\n - No duplicated content across files (if Router pattern)\n - No boilerplate sections — shared content extracted or inlined\n7. Verify 350-line limit:\n - Count lines. If over 350, list which sections to split or extract.\n8. Verify slug convention:\n - Slug present in frontmatter\n - Follows naming rules (lowercase, hyphenated, 2–4 segments)\n - If Router: children expand parent slug by one segment\n9. Write verdict to `$KAIROS_WORK_DIR/format-review.md`. First line MUST be `PASS` or `FAIL`. Remaining lines: list of specific fixes if FAIL.\n\n**Output:** `$KAIROS_WORK_DIR/format-review.md` with verdict on first line.\n\n**If fail:** Main agent applies fixes to the draft and re-runs this step until pass.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"test -f \\\"$KAIROS_WORK_DIR/format-review.md\\\" && head -1 \\\"$KAIROS_WORK_DIR/format-review.md\\\" | grep -qi 'pass'\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## Stranger Review [SUBAGENT]\n\nDelegate executability review to a subagent with junior AI agent persona. The subagent writes its verdict to `$KAIROS_WORK_DIR/stranger-review.md`.\n\n**Input:** `$KAIROS_WORK_DIR/draft-protocol.md` (post format-review fixes).\n\n**Subagent task:**\n\n1. Assume persona: Junior AI agent, first time encountering KAIROS protocols.\n2. **Mocked dry-run (most important):** Walk through every step in order and produce a mocked but **structurally correct** challenge response. If a mock is wrong, the protocol is ambiguous.\n - **`mcp` challenges:** Return valid MCP tool-call JSON with correct `tool_name`, plausible `arguments`, and realistic `result` envelope. No placeholder strings.\n - **`shell` challenges:** Write the exact command. If non-destructive, show expected stdout/stderr and exit code. Destructive: show command only.\n - **`user_input` challenges:** Write a realistic user response matching all constraints. If choice implied, pick one and justify.\n - **`comment` challenges:** Write a realistic agent comment meeting `min_length`, covering the step's stated output, no filler.\n3. **Clarity checks** (alongside dry-run):\n - **Executability test:** Can I follow step-by-step without guessing? (yes/no + explanation)\n - **Ambiguity check:** Vague terms like \"appropriate\", \"reasonable\", \"as needed\"? (list every instance)\n - **Missing context:** Steps referencing undefined variables or concepts? (list them)\n - **Missing examples:** Complex rules without examples? (list them)\n4. Write verdict to `$KAIROS_WORK_DIR/stranger-review.md`. First line MUST be `PASS` or `FAIL`. Remaining lines: mocked dry-run responses and clarity check results. If FAIL, include specific gaps with the failing mock inline.\n\n**Output:** `$KAIROS_WORK_DIR/stranger-review.md` with verdict on first line and full dry-run.\n\n**If fail:** Main agent revises draft — replace vague terms, add examples, define missing variables, fix steps whose mock drifted from intent. Re-run until pass.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"test -f \\\"$KAIROS_WORK_DIR/stranger-review.md\\\" && head -1 \\\"$KAIROS_WORK_DIR/stranger-review.md\\\" | grep -qi 'pass'\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## Checksum Freeze [SUBAGENT]\n\nFreeze the draft after both reviews pass. Prevents accidental edits between \"reviews passed\" and \"user approved\".\n\n**Input:** `$KAIROS_WORK_DIR/draft-protocol.md` (post both reviews).\n\n**Actions:**\n1. Compute md5 checksum of the draft file.\n2. Write checksum to `$KAIROS_WORK_DIR/draft-protocol.md.md5`.\n\n**Output:** `$KAIROS_WORK_DIR/draft-protocol.md.md5` containing the frozen checksum.\n\n```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"md5 -q \\\"$KAIROS_WORK_DIR/draft-protocol.md\\\" > \\\"$KAIROS_WORK_DIR/draft-protocol.md.md5\\\" && test -s \\\"$KAIROS_WORK_DIR/draft-protocol.md.md5\\\"\",\"timeout_seconds\":5},\"required\":true}}\n```\n\n## User Review [SUBAGENT]\n\nPresent the drafted and reviewed protocol to the user for final approval.\n\n**Input:** `$KAIROS_WORK_DIR/draft-protocol.md`, `$KAIROS_WORK_DIR/format-review.md`, `$KAIROS_WORK_DIR/stranger-review.md`.\n\n**Actions:**\n1. Present full protocol markdown (or all files if Router pattern).\n2. Summarize: pattern used, step count, challenge types, slug(s), both review verdicts.\n3. Ask: \"Type 'approved' to mint, describe what needs adjustment, or 'cancel'.\"\n\n**Output:** User approval, change requests, or cancellation.\n\n```json\n{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"Review the protocol draft above. Type 'approved' to mint, describe adjustments, or 'cancel'.\"},\"required\":true}}\n```\n\n## Mint Protocol [SUBAGENT]\n\nVerify the draft is unchanged since checksum freeze, then call `kairos_mint`.\n\n**Input:** Approved `$KAIROS_WORK_DIR/draft-protocol.md`, slug from frontmatter.\n\n**Actions:**\n1. Verify draft unchanged: `md5 -q \"$KAIROS_WORK_DIR/draft-protocol.md\" | diff - \"$KAIROS_WORK_DIR/draft-protocol.md.md5\"`. If diff fails, warn user and abort.\n2. Call `kairos_mint` with `force_update: false` (unless user explicitly asked to overwrite).\n3. If Router pattern: mint the router first, then each extension in order.\n4. Verify each mint succeeded by checking the returned URI.\n5. Report the chain head URI(s) back to the user with clickable links.\n\n**Output:** Confirmation with minted URI(s) and slug(s).\n\n```json\n{\"challenge\":{\"type\":\"mcp\",\"mcp\":{\"tool_name\":\"kairos_mint\"},\"required\":true}}\n```\n\n## Completion Rule\n\nOnly reachable after all prior steps are solved.\n\n**Cleanup:** `$KAIROS_WORK_DIR` is cleaned up by the engine at `kairos_attest`.\n\nThe user now has a minted KAIROS protocol that:\n1. Passed Format Review — structure, DRY, 350-line limit, slug convention, challenge type selection.\n2. Passed Stranger Review — mocked dry-run with structurally correct challenge responses, unambiguous, executable by a junior AI agent.\n3. Checksum verified — draft unchanged between review pass and mint.\n4. User approved the final draft.\n5. Successfully minted to KAIROS and discoverable via `kairos_search`.\n",
|
|
36
|
+
"challenge-type-guide": "---\nversion: \"3.4.0\"\nslug: challenge-type-guide\ntitle: Challenge Type Selection Guide\n---\n\n# Challenge Type Selection Guide\n\nDecision rules, JSON formats, interpreter selection, and anti-patterns for choosing KAIROS challenge types. Loaded by protocol-authoring agents during drafting and review.\n\n## Natural Language Triggers\n\n**Typically invoked by:** `create-new-protocol` (Chain 1) Draft Markdown step and `create-new-protocol-review` (Chain 2) Format Review step via `kairos_begin(key: \"challenge-type-guide\")`.\n\n**Can be invoked directly when agent needs:**\n\n- \"challenge type reference\" / \"which challenge type to use\"\n- \"how to write shell challenges\" / \"challenge format\"\n- \"interpreter selection for challenges\"\n\n**Trigger pattern:** **challenge** + (type | format | selection | guide).\n\n**Must Never:**\n- Be used as an execution protocol — this is a reference policy, not a workflow.\n\n**Must Always:**\n- Be consulted before assigning challenge types to protocol steps.\n\n**Good trigger examples:**\n- Drafting a new protocol and need challenge types → load this\n- Reviewing challenge type selection in a draft → load this\n\n**Bad trigger examples:**\n- \"Create a new protocol\" → use `create-new-protocol`\n- \"Review my protocol draft\" → use `create-new-protocol-review`\n\n---\n\n## Core Rules\n\n`comment` is the challenge type of **last resort**. If a step produces any observable artifact — a file, a git state change, an API response, a process exit code — use `shell` or `mcp` instead.\n\n### Decision Tree\n\n```\nDoes the step call an MCP tool?\n ├─ YES → \"mcp\" with tool_name\n └─ NO → Does the step produce or modify a file?\n ├─ YES → \"shell\" to verify the file\n └─ NO → Does the step require human approval or choice?\n ├─ YES → \"user_input\" with a specific prompt\n └─ NO → Does the step run a command or check system state?\n ├─ YES → \"shell\"\n └─ NO → \"comment\" (pure reasoning, no artifact)\n```\n\n### Challenge JSON Formats\n\n**shell** — engine runs command, checks exit code 0:\n\nExample: ```json\n{\"challenge\":{\"type\":\"shell\",\"shell\":{\"cmd\":\"<command>\",\"timeout_seconds\":30},\"required\":true}}\n```\n\n**mcp** — engine confirms named MCP tool was invoked:\n\nExample: ```json\n{\"challenge\":{\"type\":\"mcp\",\"mcp\":{\"tool_name\":\"<tool>\"},\"required\":true}}\n```\n\nWith pinned arguments:\n\nExample: ```json\n{\"challenge\":{\"type\":\"mcp\",\"mcp\":{\"tool_name\":\"kairos_begin\",\"arguments\":{\"key\":\"some-slug\"}},\"required\":true}}\n```\n\n**user_input** — engine confirms user provided non-empty response:\n\nExample: ```json\n{\"challenge\":{\"type\":\"user_input\",\"user_input\":{\"prompt\":\"<specific question>\"},\"required\":true}}\n```\n\n**comment** — engine checks min_length only (last resort):\n\nExample: ```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":50},\"required\":true}}\n```\n\n### Shell Challenge Rules\n\n- Chain checks with `&&` (not `;`) — first failure short-circuits.\n- Always set `timeout_seconds`: 5s for local checks, 30–120s for network/build.\n- All file paths MUST use `$KAIROS_WORK_DIR/` prefix (never hardcoded `/tmp/`).\n- Use `test -f` for existence, `grep -q` for content, `wc -l | awk` for line counts.\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":30},\"required\":true}}\n```\n\n---\n\n## Interpreter Selection\n\nFor text validation, regex, and structural checks, **Perl is often shorter, clearer, and more correct** than bash.\n\n| Task | Use bash | Use perl | Use python3 |\n|---|---|---|---|\n| File exists, tool installed, git state | `test -f`, `which`, `git status` | -- | -- |\n| Simple content grep | `grep -q 'pattern' file` | -- | -- |\n| Multi-line regex | -- | `perl -0777 -ne '/pat/ms or die'` | -- |\n| Count + assert (headings, sections) | `grep -c \\| awk` (fragile) | `perl -0777 -ne '@m=/pat/g; die if @m<N'` | -- |\n| Paragraph processing (commits, blocks) | `while read` loop (messy) | `perl -00 -ne '...'` | -- |\n| JSON validation | `python3 -m json.tool` | `perl -MJSON -e 'decode_json(do{local$/;<>})'` | `python3 -c 'import json; ...'` |\n| YAML validation | -- | -- | `python3 -c 'import yaml; ...'` |\n| Complex data structure checks | -- | -- | `python3 -c 'import json; d=json.load(...); assert ...'` |\n\n**Rule of thumb:** If you're writing `grep | awk`, `while read`, nested escaping, or multi-line patterns in bash — rewrite in Perl. If you need `import` for a data format (YAML, TOML) — use Python.\n\n### Perl Flags Cheat Sheet\n\n| Flag | Effect | Use case |\n|---|---|---|\n| `-e '...'` | Execute code | Every Perl challenge |\n| `-n` | Implicit `while(<>)` loop, no auto-print | Process lines, filter |\n| `-p` | Like `-n` but auto-prints `$_` | Transform-and-verify |\n| `-l` | Auto-chomp + auto-newline | Clean line processing |\n| `-a` | Auto-split into `@F` (like awk) | Field extraction |\n| `-0777` | Slurp entire file as one string | Multi-line regex |\n| `-00` | Paragraph mode (split on blank lines) | Commit messages, markdown blocks |\n| `-MJSON` | Load core JSON module | JSON validation without Python |\n\n### Bash vs Perl Examples\n\n**Count H2 headings and verify required sections:**\n\nbash (fragile):\n\nExample: ```bash\ngrep -c '^## ' \"$D\" | awk '$1 >= 3' && grep -q '^## Natural Language Triggers' \"$D\" && grep -q '^## Completion Rule' \"$D\"\n```\n\nperl (one pass, clear logic):\n\nExample: ```bash\nperl -0777 -ne '@h=/^## (.+)/mg; die \"Need >=3 H2s\" if @h<3; grep(/^Natural Language Triggers$/,@h) or die \"Missing NLT\"; grep(/^Completion Rule$/,@h) or die \"Missing CR\"' \"$D\"\n```\n\n**Validate JSON challenge blocks:**\n\nperl (core JSON module):\n\nExample: ```bash\nperl -MJSON -0777 -ne '@b=/```json\\s*\\n(\\{.*?\\})\\s*\\n```/gs; die \"No blocks\" unless @b; eval{decode_json($_)} or die \"Bad JSON: $@\" for @b; print scalar(@b).\" valid\\n\"' \"$D\"\n```\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":30},\"required\":true}}\n```\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why It Fails | Fix |\n|---|---|---|\n| `comment` with `min_length: 20` | Trivially satisfiable with filler | Raise to 50+, or switch to `shell` if artifact exists |\n| `comment` for steps that run commands | Says \"run X\" but only checks agent wrote words | Use `shell` with the actual command |\n| `comment` for steps that call MCP tools | Says \"call tool Y\" but only checks text output | Use `mcp` with `tool_name` |\n| `shell` without `timeout_seconds` | May hang indefinitely | Always set timeout |\n| `user_input` with generic prompt \"Confirm\" | User doesn't know what they're confirming | Write a specific question |\n| `shell` with `echo 'placeholder'` | Always passes, proves nothing | Replace with real verification command |\n| Checks chained with `;` instead of `&&` | Later checks run even if earlier ones fail | Use `&&` for short-circuit |\n| Hardcoded `/tmp/` paths | Concurrent runs collide; world-readable on Linux | Use `$KAIROS_WORK_DIR` |\n| bash `while read \\| grep \\| awk` chains | Fragile, escaping nightmare, non-portable | Rewrite in Perl |\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":30},\"required\":true}}\n```\n\n---\n\n## Security and Concurrency\n\n### Session-Scoped Working Directory\n\nNever use hardcoded `/tmp/` paths. Use a session-scoped, user-private working directory:\n\nExample: ```bash\nexport KAIROS_WORK_DIR=$(mktemp -d \"${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/kairos-XXXXXX\")\nchmod 700 \"$KAIROS_WORK_DIR\"\n```\n\n**Priority chain:** `XDG_RUNTIME_DIR` (preferred, per-user, `0700` by spec) → `TMPDIR` (macOS fallback) → `/tmp` (last resort, `chmod 700`).\n\n**Why:** Concurrent chat sessions running the same protocol would collide on hardcoded paths. `mktemp -d` guarantees isolation. Completion Rule MUST `rm -rf \"$KAIROS_WORK_DIR\"`.\n\n**Rules:** All file paths in shell challenges use `$KAIROS_WORK_DIR/` prefix. Prerequisites section creates it. Completion Rule cleans it up. Never write credentials or secrets to files.\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":30},\"required\":true}}\n```\n\n---\n\n## Composition Patterns\n\n**Multi-check compound command** — chain with `&&`, first failure short-circuits:\n\nExample: ```bash\ntest -f <file> && grep -q '<required>' <file> && wc -l < <file> | awk '$1 <= 350'\n```\n\n**Freeze-then-verify** — two consecutive steps:\n- Step N (after review): `md5 -q <file> > \"$KAIROS_WORK_DIR/<file>.md5\"`\n- Step N+1 (before publish): `md5 -q <file> | diff - \"$KAIROS_WORK_DIR/<file>.md5\"`\n\n**Write-then-grep** — subagent delegation:\n- Subagent instruction: \"Write verdict to `$KAIROS_WORK_DIR/<name>.md`. First line: `PASS` or `FAIL`.\"\n- Main agent challenge: `head -1 \"$KAIROS_WORK_DIR/<name>.md\" | grep -qi 'pass'`\n\n**Dry-run before execution** — three steps:\n- Step N: `<tool> --dry-run` (shell challenge)\n- Step N+1: `user_input` (human reviews output)\n- Step N+2: `<tool> --yes` (shell challenge)\n\n```json\n{\"challenge\":{\"type\":\"comment\",\"comment\":{\"min_length\":30},\"required\":true}}\n```\n\n## Completion Rule\n\nOnly reachable after all prior steps are solved.\n\nThe agent has loaded the challenge type selection guide and can now:\n1. Pick the correct challenge type for each protocol step using the decision tree.\n2. Write valid challenge JSON in the correct format.\n3. Choose the right interpreter (bash / perl / python3) for shell challenges.\n4. Avoid all listed anti-patterns.\n5. Apply security and concurrency rules (`$KAIROS_WORK_DIR`).\n6. Use composition patterns for multi-check, freeze-verify, and subagent delegation.\n"
|
|
37
|
+
}
|
|
32
38
|
};
|
|
33
39
|
/**
|
|
34
40
|
* Get prompts object
|
|
@@ -60,6 +66,12 @@ export function getTools() {
|
|
|
60
66
|
export function getMem() {
|
|
61
67
|
return mcpResources.mem || {};
|
|
62
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Get meta object
|
|
71
|
+
*/
|
|
72
|
+
export function getMeta() {
|
|
73
|
+
return mcpResources.meta || {};
|
|
74
|
+
}
|
|
63
75
|
/**
|
|
64
76
|
* Get a prompt by key (e.g. 'contextual-prompt')
|
|
65
77
|
*/
|
|
@@ -71,8 +83,12 @@ export function getPrompt(key) {
|
|
|
71
83
|
* Get a resource by key (e.g. 'TEST', 'doc.TEST', 'mem.<uuid>')
|
|
72
84
|
*/
|
|
73
85
|
export function getResource(key) {
|
|
74
|
-
const resources = (mcpResources.resources || {});
|
|
75
86
|
const parts = key.split('.');
|
|
87
|
+
if (parts[0] === 'meta' && parts.length === 2) {
|
|
88
|
+
const meta = (mcpResources.meta || {});
|
|
89
|
+
return meta[parts[1]];
|
|
90
|
+
}
|
|
91
|
+
const resources = (mcpResources.resources || {});
|
|
76
92
|
let current = resources;
|
|
77
93
|
for (const part of parts) {
|
|
78
94
|
if (current && typeof current === 'object') {
|
|
@@ -84,6 +100,13 @@ export function getResource(key) {
|
|
|
84
100
|
}
|
|
85
101
|
return current;
|
|
86
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Meta protocol / policy markdown by slug (from frontmatter).
|
|
105
|
+
*/
|
|
106
|
+
export function getMetaDoc(slug) {
|
|
107
|
+
const meta = (mcpResources.meta || {});
|
|
108
|
+
return meta[slug];
|
|
109
|
+
}
|
|
87
110
|
/**
|
|
88
111
|
* Get a template by key (e.g. 'kairos-memory')
|
|
89
112
|
*/
|
|
@@ -106,10 +129,11 @@ export function listResourceKeys() {
|
|
|
106
129
|
const resources = collectAllKeys((mcpResources.resources || {}));
|
|
107
130
|
const templates = Object.keys((mcpResources.templates || {}));
|
|
108
131
|
const tools = Object.keys((mcpResources.tools || {}));
|
|
109
|
-
const
|
|
132
|
+
const meta = Object.keys((mcpResources.meta || {}));
|
|
133
|
+
const result = { prompts, resources, templates, tools, meta };
|
|
110
134
|
// Add any other top-level categories
|
|
111
135
|
for (const [key, value] of Object.entries(mcpResources)) {
|
|
112
|
-
if (!['prompts', 'resources', 'templates', 'tools'].includes(key)) {
|
|
136
|
+
if (!['prompts', 'resources', 'templates', 'tools', 'meta'].includes(key)) {
|
|
113
137
|
if (typeof value === 'object' && value !== null) {
|
|
114
138
|
result[key] = Object.keys(value);
|
|
115
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-mcp-resources.js","sourceRoot":"","sources":["../../src/resources/embedded-mcp-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE;QACT,mBAAmB,EAAE,4yBAA4yB;KACl0B;IACD,WAAW,EAAE;QACX,2BAA2B,EAAE
|
|
1
|
+
{"version":3,"file":"embedded-mcp-resources.js","sourceRoot":"","sources":["../../src/resources/embedded-mcp-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,EAAE;QACT,mBAAmB,EAAE,4yBAA4yB;KACl0B;IACD,WAAW,EAAE;QACX,2BAA2B,EAAE,spVAAspV;KACprV;IACD,WAAW,EAAE;QACX,eAAe,EAAE,y6CAAy6C;KAC37C;IACD,OAAO,EAAE;QACP,eAAe,EAAE,4+CAA4+C;QAC7/C,cAAc,EAAE,yyIAAyyI;QACzzI,eAAe,EAAE,4kBAA4kB;QAC7lB,aAAa,EAAE,mwCAAmwC;QAClxC,aAAa,EAAE,skHAAskH;QACrlH,aAAa,EAAE,irGAAirG;QAChsG,eAAe,EAAE,69EAA69E;QAC9+E,eAAe,EAAE,43BAA43B;QAC74B,eAAe,EAAE,yoCAAyoC;KAC3pC;IACD,KAAK,EAAE,EAAE;IACT,MAAM,EAAE;QACN,qBAAqB,EAAE,okYAAokY;QAC3lY,eAAe,EAAE,+/GAA+/G;QAChhH,4BAA4B,EAAE,ukTAAukT;QACrmT,sBAAsB,EAAE,yoTAAyoT;KAClqT;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,CAAC,OAAO,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OA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,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,GAAQ,EAAE,SAAiB,EAAE,EAAE,OAAiB,EAAE;IACxE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACvD,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mem-resources-boot.d.ts","sourceRoot":"","sources":["../../src/resources/mem-resources-boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"mem-resources-boot.d.ts","sourceRoot":"","sources":["../../src/resources/mem-resources-boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAsEhE;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,iBAAiB,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgH/H"}
|
|
@@ -5,6 +5,8 @@ import { KAIROS_APP_SPACE_ID } from '../config.js';
|
|
|
5
5
|
import { readdir, readFile } from 'fs/promises';
|
|
6
6
|
import { join, dirname, basename } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
+
/** Mem markdown whose basename (no .md) is a UUID — inject as kairos://mem/{uuid}. */
|
|
9
|
+
const MEM_FILE_UUID_KEY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
10
|
/**
|
|
9
11
|
* Get the directory containing mem files at runtime
|
|
10
12
|
* Works in both development (src/) and production (dist/)
|
|
@@ -91,10 +93,16 @@ export async function injectMemResourcesAtBoot(memoryStore, options = {}) {
|
|
|
91
93
|
for (const [key, markdownContent] of Object.entries(memResources)) {
|
|
92
94
|
if (typeof markdownContent !== 'string')
|
|
93
95
|
continue;
|
|
96
|
+
if (!MEM_FILE_UUID_KEY.test(key)) {
|
|
97
|
+
structuredLogger.debug(`[mem-resources-boot] Skip non-UUID mem key: ${key}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
94
100
|
const targetUuid = key; // Use key (filename) as UUID
|
|
95
101
|
try {
|
|
96
|
-
// Use storeChain to handle parsing, embeddings, and force update logic
|
|
97
|
-
//
|
|
102
|
+
// Use storeChain to handle parsing, embeddings, and force update logic.
|
|
103
|
+
// Always forceUpdate on storeChain so a prior boot (e.g. old step-1 UUID before filename change)
|
|
104
|
+
// does not leave a same-label chain that blocks minting the canonical file UUID (DUPLICATE_CHAIN / DUPLICATE_SLUG).
|
|
105
|
+
// Per-file skip when target UUID already exists (below) still avoids re-embedding on normal restarts.
|
|
98
106
|
if (options.force) {
|
|
99
107
|
try {
|
|
100
108
|
await qdrantService.deleteMemory(targetUuid);
|
|
@@ -116,7 +124,7 @@ export async function injectMemResourcesAtBoot(memoryStore, options = {}) {
|
|
|
116
124
|
// Continue if check fails
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
|
-
const memories = await memoryStore.storeChain([markdownContent], llmModelId, { forceUpdate:
|
|
127
|
+
const memories = await memoryStore.storeChain([markdownContent], llmModelId, { forceUpdate: true });
|
|
120
128
|
if (memories.length > 0) {
|
|
121
129
|
// Only the first step is remapped to the file UUID; other steps of the same chain keep server-generated IDs.
|
|
122
130
|
const storedMemory = memories[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mem-resources-boot.js","sourceRoot":"","sources":["../../src/resources/mem-resources-boot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;GAGG;AACH,SAAS,SAAS;IAChB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,8DAA8D;IAC9D,2DAA2D;IAC3D,6FAA6F;IAC7F,uDAAuD;IACvD,MAAM,OAAO,G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,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for reconciling chain step_count with Qdrant chain points.
|
|
3
|
+
*/
|
|
4
|
+
/** Largest step_index seen on chain points (0 if none). */
|
|
5
|
+
export declare function maxStepIndexFromChainPoints(points: Array<{
|
|
6
|
+
payload?: {
|
|
7
|
+
chain?: {
|
|
8
|
+
step_index?: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}>): number;
|
|
12
|
+
/**
|
|
13
|
+
* Trust Qdrant chain points over embedded step_count when they disagree (Redis/process cache
|
|
14
|
+
* can serve a stale step_count while siblings still exist in Qdrant).
|
|
15
|
+
*/
|
|
16
|
+
export declare function effectiveChainStepCount(points: Array<{
|
|
17
|
+
payload?: {
|
|
18
|
+
chain?: {
|
|
19
|
+
step_index?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}>, memoryStepCount: number | undefined): number;
|
|
23
|
+
//# sourceMappingURL=chain-step-count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-step-count.d.ts","sourceRoot":"","sources":["../../src/services/chain-step-count.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2DAA2D;AAC3D,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,UAAU,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,GAAG,MAAM,CAOpH;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,KAAK,CAAC;IAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,UAAU,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAAC,EAChE,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC,MAAM,CAIR"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for reconciling chain step_count with Qdrant chain points.
|
|
3
|
+
*/
|
|
4
|
+
/** Largest step_index seen on chain points (0 if none). */
|
|
5
|
+
export function maxStepIndexFromChainPoints(points) {
|
|
6
|
+
let max = 0;
|
|
7
|
+
for (const pt of points) {
|
|
8
|
+
const step = pt.payload?.chain?.step_index;
|
|
9
|
+
if (typeof step === 'number' && step > max)
|
|
10
|
+
max = step;
|
|
11
|
+
}
|
|
12
|
+
return max;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Trust Qdrant chain points over embedded step_count when they disagree (Redis/process cache
|
|
16
|
+
* can serve a stale step_count while siblings still exist in Qdrant).
|
|
17
|
+
*/
|
|
18
|
+
export function effectiveChainStepCount(points, memoryStepCount) {
|
|
19
|
+
const fromMemory = typeof memoryStepCount === 'number' && memoryStepCount >= 1 ? memoryStepCount : 0;
|
|
20
|
+
const fromPayload = maxStepIndexFromChainPoints(points);
|
|
21
|
+
return Math.max(fromMemory, fromPayload);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=chain-step-count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-step-count.js","sourceRoot":"","sources":["../../src/services/chain-step-count.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2DAA2D;AAC3D,MAAM,UAAU,2BAA2B,CAAC,MAAgE;IAC1G,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC;QAC3C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,GAAG,GAAG;YAAE,GAAG,GAAG,IAAI,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAgE,EAChE,eAAmC;IAEnC,MAAM,UAAU,GAAG,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,MAAM,WAAW,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-utils.d.ts","sourceRoot":"","sources":["../../src/services/chain-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"chain-utils.d.ts","sourceRoot":"","sources":["../../src/services/chain-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAoBD,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAkBrD;AAED,wBAAsB,qBAAqB,CACvC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAexC;AAED,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAgBxC;AAED,wBAAsB,wBAAwB,CAC1C,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAexC"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { qdrantService as globalQdrantService } from './qdrant/index.js';
|
|
2
|
-
|
|
2
|
+
import { effectiveChainStepCount } from './chain-step-count.js';
|
|
3
|
+
async function getChainPoints(chainId, qdrantService, extraSpaceIds) {
|
|
3
4
|
const svc = qdrantService || globalQdrantService;
|
|
4
5
|
if (!svc || typeof svc.getChainMemories !== 'function')
|
|
5
6
|
return [];
|
|
6
7
|
try {
|
|
7
|
-
return await svc.getChainMemories(chainId);
|
|
8
|
+
return await svc.getChainMemories(chainId, extraSpaceIds);
|
|
8
9
|
}
|
|
9
10
|
catch {
|
|
10
11
|
return [];
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
function anchorSpaces(memory) {
|
|
15
|
+
return memory.space_id ? [memory.space_id] : undefined;
|
|
16
|
+
}
|
|
13
17
|
export async function resolveFirstStep(memory, qdrantService) {
|
|
14
18
|
if (!memory.chain || memory.chain.step_index === 1) {
|
|
15
19
|
return { uri: `kairos://mem/${memory.memory_uuid}`, label: String(memory.label || 'Memory') };
|
|
16
20
|
}
|
|
17
|
-
const points = await getChainPoints(memory.chain.id, qdrantService);
|
|
21
|
+
const points = await getChainPoints(memory.chain.id, qdrantService, anchorSpaces(memory));
|
|
18
22
|
if (!Array.isArray(points) || points.length === 0)
|
|
19
23
|
return { uri: `kairos://mem/${memory.memory_uuid}`, label: String(memory.label || 'Memory') };
|
|
20
24
|
const head = points
|
|
@@ -31,7 +35,7 @@ export async function resolveFirstStep(memory, qdrantService) {
|
|
|
31
35
|
export async function resolveChainFirstStep(memory, qdrantService) {
|
|
32
36
|
if (!memory.chain)
|
|
33
37
|
return undefined;
|
|
34
|
-
const points = await getChainPoints(memory.chain.id, qdrantService);
|
|
38
|
+
const points = await getChainPoints(memory.chain.id, qdrantService, anchorSpaces(memory));
|
|
35
39
|
if (!Array.isArray(points) || points.length === 0)
|
|
36
40
|
return undefined;
|
|
37
41
|
const first = points
|
|
@@ -49,10 +53,11 @@ export async function resolveChainFirstStep(memory, qdrantService) {
|
|
|
49
53
|
export async function resolveChainNextStep(memory, qdrantService) {
|
|
50
54
|
if (!memory.chain)
|
|
51
55
|
return undefined;
|
|
52
|
-
const { id: chainId, step_index: idx, step_count:
|
|
53
|
-
|
|
56
|
+
const { id: chainId, step_index: idx, step_count: memoryCount } = memory.chain;
|
|
57
|
+
const points = await getChainPoints(chainId, qdrantService, anchorSpaces(memory));
|
|
58
|
+
const effectiveCount = effectiveChainStepCount(points, memoryCount);
|
|
59
|
+
if (effectiveCount < 1 || idx >= effectiveCount)
|
|
54
60
|
return undefined;
|
|
55
|
-
const points = await getChainPoints(chainId, qdrantService);
|
|
56
61
|
if (!Array.isArray(points) || points.length === 0)
|
|
57
62
|
return undefined;
|
|
58
63
|
const next = points
|
|
@@ -63,7 +68,7 @@ export async function resolveChainNextStep(memory, qdrantService) {
|
|
|
63
68
|
}))
|
|
64
69
|
.find(p => p.step === idx + 1);
|
|
65
70
|
if (next && next.uuid)
|
|
66
|
-
return { uuid: next.uuid, label: next.label, step: next.step, count };
|
|
71
|
+
return { uuid: next.uuid, label: next.label, step: next.step, count: effectiveCount };
|
|
67
72
|
return undefined;
|
|
68
73
|
}
|
|
69
74
|
export async function resolveChainPreviousStep(memory, qdrantService) {
|
|
@@ -72,7 +77,7 @@ export async function resolveChainPreviousStep(memory, qdrantService) {
|
|
|
72
77
|
const { id: chainId, step_index: idx, step_count: count } = memory.chain;
|
|
73
78
|
if (idx <= 1)
|
|
74
79
|
return undefined;
|
|
75
|
-
const points = await getChainPoints(chainId, qdrantService);
|
|
80
|
+
const points = await getChainPoints(chainId, qdrantService, anchorSpaces(memory));
|
|
76
81
|
if (!Array.isArray(points) || points.length === 0)
|
|
77
82
|
return undefined;
|
|
78
83
|
const prev = points
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-utils.js","sourceRoot":"","sources":["../../src/services/chain-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"chain-utils.js","sourceRoot":"","sources":["../../src/services/chain-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAShE,KAAK,UAAU,cAAc,CACzB,OAAe,EACf,aAAmB,EACnB,aAAwB;IAExB,MAAM,GAAG,GAAG,aAAa,IAAI,mBAAmB,CAAC;IACjD,IAAI,CAAC,GAAG,IAAI,OAAQ,GAAW,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IAC3E,IAAI,CAAC;QACD,OAAO,MAAO,GAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAChC,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,MAAc,EACd,aAAmB;IAEnB,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE,GAAG,EAAE,gBAAgB,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,QAAQ,CAAC,EAAE,CAAC;IAClG,CAAC;IAED,MAAM,MAAM,GAAU,MAAM,cAAc,CAAC,MAAM,CAAC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