Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(mcp): tool description template, key dependence, no release jargon; list_jobs fields projection (F10)
garrytan1b88c96469ff
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.mdindex 95b097ce73..3368d6261b 100644--- a/docs/TOOL_CATALOG.md+++ b/docs/TOOL_CATALOG.md@@ -73,8 +73,8 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `get_ingest_log` | Get recent ingestion log entries | read | yes | |-| `log_ingest` | Log an ingestion event | write | | |+| `get_ingest_log` | List recent ingestion events (what was imported, from where, which pages changed). | read | yes | |+| `log_ingest` | Record one ingestion event (source type, reference, pages updated, summary) in the brain's ingest log. | write | | |## insights@@ -83,7 +83,7 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| `find_anomalies` | Returns statistical anomalies in recent page activity, grouped by cohort (tag or type). | read | yes | || `find_contradictions` | Stored contradiction reports are temporarily available only to trusted local callers without a source filter. | read | | || `find_experts` | Answers 'who in my brain knows about <topic>'. | read | | |-| `find_trajectory` | v0.35.4 — return the chronological claim trajectory for an entity (typed metric values over time, plus auto-detected regressions and narrative drift). | read | | |+| `find_trajectory` | Return the chronological claim trajectory for an entity (typed metric values over time, plus auto-detected regressions and narrative drift). | read | | || `get_calibration_profile` | Read the active calibration profile for a holder. | read | | || `get_recent_salience` | Returns readable pages recently touched and ranked by activity salience and recency. | read | yes | || `volunteer_context` | Push-based context: volunteer brain pages relevant to a rolling conversation window WITHOUT being asked. | read | | |@@ -97,12 +97,12 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| `get_job` | Get job status and details by ID. | admin | | || `get_job_progress` | Get structured progress for a running job. | admin | | || `get_job_stats` | Job queue statistics. | admin | | |-| `list_jobs` | List jobs with optional filters. | admin | | |-| `pause_job` | Pause a waiting, active, or delayed job | admin | | |+| `list_jobs` | List background jobs with optional status/queue/name filters; pass fields to project each job to the columns you need. | admin | | |+| `pause_job` | Pause a waiting, active or delayed background job. | admin | | || `replay_job` | Replay a completed/failed/dead job, optionally with modified data | admin | | |-| `resume_job` | Resume a paused job back to waiting | admin | | |-| `retry_job` | Re-queue a failed or dead job for retry | admin | | |-| `send_job_message` | Send a sidechannel message to a running job's inbox | admin | | |+| `resume_job` | Resume a paused background job (back to waiting). | admin | | |+| `retry_job` | Re-queue a failed or dead background job. | admin | | |+| `send_job_message` | Send a sidechannel message to a running job's inbox (for jobs that read steering messages). | admin | | || `submit_agent` | Submit an LLM agent job that the worker dispatches via the gateway-native tool loop. | agent | yes | || `submit_job` | Submit a background job. | admin | | |@@ -110,12 +110,12 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `add_link` | Create link between pages | write | | |+| `add_link` | Create a typed link (edge) from one page to another in the same source. | write | | || `find_orphans` | Find disconnected pages. | read | | |-| `get_backlinks` | List incoming links to a page | read | yes | |-| `get_links` | List outgoing links from a page | read | | |+| `get_backlinks` | List a page's incoming links (who points at it). | read | yes | |+| `get_links` | List a page's outgoing links (typed edges to other pages). | read | | || `list_link_sources` | List distinct link_source provenances in the brain with edge counts (e.g. | read | yes | |-| `remove_link` | Remove link between pages | write | | |+| `remove_link` | Remove a link between two pages (optionally only one link_type or link_source). | write | | || `traverse_graph` | Traverse link graph from a page. | read | yes | |## loops@@ -131,7 +131,7 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `extract_facts` | v0.31: extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. | write | | |+| `extract_facts` | Extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. | write | | || `forget_fact` | Forget a fact by recording a durable withdrawal in its source and visibility. | write | | |## memory-verbs@@ -164,7 +164,7 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| `delete_page` | Soft-delete a page and remove its markdown file from the source working tree (the source local_path, or sync.repo_path when the source has none). | write | | || `edit_page` | Change part of an existing page without resending it: prefer this over put_page for small changes to large pages. | write | yes | || `fetch` | Fetch the full text of one search result by its opaque, source-qualified `id` (OpenAI deep-research contract: the search/fetch pair). | read | | |-| `get_chunks` | Get content chunks for a page | read | | |+| `get_chunks` | Return a page's indexed content chunks (the units search ranks). | read | | || `get_page` | Read a page by slug (supports optional fuzzy matching). | read | yes | || `get_raw_data` | Retrieve raw data for a page. | read | | || `get_versions` | Page version history. | read | | |@@ -172,24 +172,24 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| `list_pages` | List pages with optional filters. | read | yes | || `list_write_requests` | List your currently authorized write receipts in one source, newest first. | write | yes | || `put_page` | Replace a complete canonical Markdown page. | write | yes | |-| `put_raw_data` | Store raw API response data for a page | write | | |-| `resolve_slugs` | Fuzzy-resolve a partial slug to matching page slugs | read | yes | |-| `restore_page` | v0.26.5 — restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). | write | | |-| `revert_version` | Revert page to a previous version | write | | |+| `put_raw_data` | Store a raw provider payload (API response JSON) alongside a page, keyed by source. | write | | |+| `resolve_slugs` | Fuzzy-match a partial name or slug to existing page slugs. | read | yes | |+| `restore_page` | Restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). | write | | |+| `revert_version` | Restore a page to an earlier version from its history (a new revision; history is kept). | write | | |## schema| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `get_active_schema_pack` | v0.40.6.0: cheap identity packet for the active schema pack. | read | | |-| `list_schema_packs` | v0.40.6.0: list installed schema packs (bundled + user-installed). | read | | |-| `reload_schema_pack` | v0.40.6.0: flush the in-process schema pack cache so the next loadActivePack re-reads from disk. | admin | | |-| `schema_apply_mutations` | v0.40.7.0: batched schema pack mutation. | admin | | |-| `schema_explain_type` | v0.40.6.0: resolved settings for a single page_type in the active pack. | read | | |-| `schema_graph` | v0.40.6.0: schema pack graph as JSON edges. | read | | |-| `schema_lint` | v0.40.6.0: lint the active (or named) schema pack. | read | | |-| `schema_review_orphans` | v0.40.6.0: list pages with no active-pack type match. | read | | |-| `schema_stats` | v0.40.6.0: per-type page counts + typed-coverage from the DB. | read | | |+| `get_active_schema_pack` | Cheap identity packet for the active schema pack. | read | | |+| `list_schema_packs` | List installed schema packs (bundled + user-installed). | read | | |+| `reload_schema_pack` | Flush the in-process schema pack cache so the next loadActivePack re-reads from disk. | admin | | |+| `schema_apply_mutations` | Batched schema pack mutation. | admin | | |+| `schema_explain_type` | Resolved settings for a single page_type in the active pack. | read | | |+| `schema_graph` | Schema pack graph as JSON edges. | read | | |+| `schema_lint` | Lint the active (or named) schema pack. | read | | |+| `schema_review_orphans` | List pages with no active-pack type match. | read | | |+| `schema_stats` | Per-type page counts + typed-coverage from the DB. | read | | |## search@@ -199,7 +199,7 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| `cache_stats` | Semantic query-cache introspection: resolved knobs (enabled, similarity threshold, TTL) plus row counts and total hits. | admin | | || `query` | Hybrid search with vector + keyword + multi-query expansion. | read | yes | || `search` | Cheap hybrid search (vector + keyword + RRF) with no LLM expansion. | read | yes | |-| `search_by_image` | v0.36 cross-modal Phase 2: image-as-query retrieval. | read | | |+| `search_by_image` | Image-as-query retrieval. | read | | || `search_modes` | Read-only search-mode dashboard: active mode, EVERY mode-bundle knob resolved with attribution (mode default vs config override), the three frozen bundles, and a reranker_readiness verdict (whether the resolved reranker will actually run; remote callers get the verdict without the host key inventory). | read | | || `search_stats` | Search observability over a window: cache hit rate, intent/mode mix, budget drops, rank-1 score drift, graph-signals failure counts. | admin | | || `search_tune` | Read-only tuning recommendations derived from the last 7 days of search telemetry: what should change, why, and the paste-ready config command per recommendation — relay them to the user. | admin | | |@@ -233,9 +233,9 @@ Every non-localOnly operation on the MCP surface: 137 tools across 23 areas. **S| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `add_tag` | Add tag to page | write | | |-| `get_tags` | List tags for a page | read | | |-| `remove_tag` | Remove tag from page | write | | |+| `add_tag` | Add one tag to a page (idempotent). | write | | |+| `get_tags` | List the tags on one page. | read | | |+| `remove_tag` | Remove one tag from a page. | write | | |## takesdiff --git a/scripts/serial-weights.json b/scripts/serial-weights.jsonindex e7062dc8ae..3f99fda744 100644--- a/scripts/serial-weights.json+++ b/scripts/serial-weights.json@@ -225,6 +225,7 @@"test/self-upgrade-checkonly.serial.test.ts": 1,"test/serve-idle-sweep-source.serial.test.ts": 1,"test/serve-source-guard.serial.test.ts": 1,+ "test/serve-status-mode.serial.test.ts": 25,"test/serve-sync-ipc-killswitch.serial.test.ts": 16,"test/serve-sync-runner.serial.test.ts": 11,"test/skillopt/adversarial/concurrent-runs.serial.test.ts": 5,diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 57b047abd6..0523f01faa 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -73,7 +73,7 @@ test/cli.test.ts BigInt-safe output normalization (#2450) 5 source-surface-helpetest/cli.test.ts CLI structure 2 source-surface-helpertest/cli.test.ts CLI version 2 readFileSynctest/codex-plugin-manifest.test.ts codex mcp.json 3 readFileSync-test/codex-plugin-manifest.test.ts curated tree membership + scanner guard 5 readFileSync+test/codex-plugin-manifest.test.ts curated tree membership + scanner guard 6 readFileSynctest/codex-plugin-manifest.test.ts generator negative fixtures (a guard that cannot fail is not coverage) 9 readFileSynctest/codex-plugin-manifest.test.ts variant ${def.plugin_name} (persona ${personaName}) 5 readFileSynctest/compile-view.test.ts compileView — determinism 3 readFileSyncdiff --git a/scripts/test-weights.json b/scripts/test-weights.jsonindex 52e9cb0c67..90f73e354a 100644--- a/scripts/test-weights.json+++ b/scripts/test-weights.json@@ -1099,6 +1099,7 @@"test/markdown.test.ts": 11,"test/mcp-admin-http.test.ts": 118,"test/mcp-administration-guidance.test.ts": 2,+ "test/mcp-capabilities-readiness.test.ts": 2500,"test/mcp-client-hardening.test.ts": 278,"test/mcp-client-lifecycle.test.ts": 1142,"test/mcp-client.test.ts": 2347,@@ -1108,7 +1109,9 @@"test/mcp-dispatch-summarize.test.ts": 4,"test/mcp-eval-capture.test.ts": 679,"test/mcp-expose.test.ts": 307,+ "test/mcp-initialize-instructions.test.ts": 400,"test/mcp-instructions-writeback.test.ts": 37,+ "test/mcp-notice-channels.test.ts": 3500,"test/mcp-registration-blocks.test.ts": 6,"test/mcp-server-identity.test.ts": 4,"test/mcp-stdio-gate-list.test.ts": 13,@@ -1974,6 +1977,7 @@"test/token-mint-shared-skills.test.ts": 4,"test/token-mint.test.ts": 387,"test/tool-catalog.test.ts": 12,+ "test/tool-descriptions.test.ts": 2200,"test/track1-save-time-entity-resolution.test.ts": 10,"test/trajectory-format.test.ts": 8,"test/trajectory-timeout-timers.test.ts": 281,diff --git a/src/core/operations-descriptions.ts b/src/core/operations-descriptions.tsindex b80eb570c9..43bb0a2e00 100644--- a/src/core/operations-descriptions.ts+++ b/src/core/operations-descriptions.ts@@ -85,7 +85,10 @@ export const QUERY_DESCRIPTION ="'how am I feeling'), prefer get_recent_salience or find_anomalies (raw " +"transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses " +"recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' " +- "mean impressive — they often mean difficult or emotionally charged.";+ "mean impressive — they often mean difficult or emotionally charged. " ++ "Needs an embedding key for semantic recall and a chat-model key for expansion; " ++ "without them it runs keyword-only and a degraded_recall notice says so (a thin " ++ "result is then not proof of absence).";export const SEARCH_DESCRIPTION ="Cheap hybrid search (vector + keyword + RRF) with no LLM expansion. " +@@ -121,7 +124,7 @@ export const FIND_CONTRADICTIONS_DESCRIPTION ="`gbrain eval suspected-contradictions` for that.";export const FIND_TRAJECTORY_DESCRIPTION =- "v0.35.4 — return the chronological claim trajectory for an entity (typed " ++ "Return the chronological claim trajectory for an entity (typed " +"metric values over time, plus auto-detected regressions and narrative drift). " +"Use this when the user asks 'how has Acme's MRR trended', 'show me what " +"alice-example said about runway over time', 'is this founder consistent', " +@@ -150,7 +153,7 @@ export const FIND_TRAJECTORY_DESCRIPTION =export const CODE_CALLERS_DESCRIPTION ="BEFORE editing any function, run code_callers with the symbol name to find " +"every caller (the people who'd be affected by your change). Returns direct " +- "callers from the v0.20+ tree-sitter call graph. Use during plan-mode to size " ++ "callers from the tree-sitter call graph. Use during plan-mode to size " +"the change. Defaults to source-scoped; for multi-source brains pass source_id " +"or all_sources=true. " +"Returns: `{symbol, count, callers: [{from_symbol_qualified, to_symbol_qualified, edge_type, resolved}]}`. " +diff --git a/src/core/ops/admin.ts b/src/core/ops/admin.tsindex 9a9af64993..0bcb3ba3b7 100644--- a/src/core/ops/admin.ts+++ b/src/core/ops/admin.ts@@ -208,7 +208,7 @@ const revert_version: Operation = {name: 'revert_version',idempotent: true,outputRedaction: 'no_stored_text',- description: 'Revert page to a previous version',+ description: 'Restore a page to an earlier version from its history (a new revision; history is kept). Use when an edit must be undone. Needs write scope. On a revision conflict: re-read the page with get_page and resubmit with its revision.',params: {...PAGE_MUTATION_PARAMS,slug: { type: 'string', required: true, description: 'Slug of the page to revert.' },diff --git a/src/core/ops/chunks.ts b/src/core/ops/chunks.tsindex ca48a5b687..2a6756f1ef 100644--- a/src/core/ops/chunks.ts+++ b/src/core/ops/chunks.ts@@ -17,7 +17,7 @@ const resolve_slugs: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'Fuzzy-resolve a partial slug to matching page slugs',+ description: 'Fuzzy-match a partial name or slug to existing page slugs. Use when a slug is uncertain before get_page, links or tags. Needs read scope. On no matches: search for the name instead.',params: {partial: { type: 'string', required: true, description: "Partial slug or title text to match, e.g. 'alice-ex' or 'meeting notes'. This is the search text param — there is no `text` param." },source_id: {@@ -44,7 +44,7 @@ const get_chunks: Operation = {mutating: false,idempotent: true,outputRedaction: { exempt: 'explicit chunk read by slug, the page-read twin of get_page (CEO-17 raw-read exception)' },- description: 'Get content chunks for a page',+ description: 'Return a page\'s indexed content chunks (the units search ranks). Use when debugging why search did or did not match a page. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.',params: {slug: { type: 'string', required: true, description: 'Slug of the page whose content chunks to return.' },},diff --git a/src/core/ops/code-intel.ts b/src/core/ops/code-intel.tsindex 287717c441..9391a915d1 100644--- a/src/core/ops/code-intel.ts+++ b/src/core/ops/code-intel.ts@@ -278,7 +278,7 @@ const code_traversal_cache_clear: Operation = {name: 'code_traversal_cache_clear',idempotent: true,outputRedaction: 'no_stored_text',- description: 'Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (D8 destructive-guard).',+ description: 'Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (destructive: it is guarded).',params: {source_id: { type: 'string', description: 'Source to clear. Required unless all_sources=true.' },all_sources: { type: 'boolean', description: 'Wipe cache across every source. Explicit opt-out of source-scoping.' },diff --git a/src/core/ops/embedding-migration.ts b/src/core/ops/embedding-migration.tsindex c0693ed37c..dd995826a0 100644--- a/src/core/ops/embedding-migration.ts+++ b/src/core/ops/embedding-migration.ts@@ -18,7 +18,7 @@ const migrate_embeddings: Operation = {name: 'migrate_embeddings',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Re-embed the brain onto a different embedding provider/model (#3390): schema dimension transition, NULL-signature (#3391) invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.',+ description: 'Re-embed the brain onto a different embedding provider/model: schema dimension transition, NULL-signature invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.',params: {to: { type: 'string', required: true, description: 'Target provider:model (e.g. openai:text-embedding-3-small).' },dim: { type: 'number', description: "Target dimensions. Defaults to the provider recipe's declared width; required when the recipe declares none." },diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.tsindex fe06efe505..52d1711d8e 100644--- a/src/core/ops/facts.ts+++ b/src/core/ops/facts.ts@@ -44,7 +44,7 @@ const extract_facts: Operation = {idempotent: true,outputRedaction: 'no_stored_text',description:- 'v0.31: extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: "private"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).',+ 'Extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: "private"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).',params: {request_id: { ...WRITE_REQUEST_PARAM, description: `${WRITE_REQUEST_PARAM.description} Managed extraction returns durable receipts; when omitted, each call gets a new UUID. Unmanaged extraction retains its legacy non-journaled behavior.` },turn_text: { type: 'string', required: true, description: 'The user message or page body to extract facts from. Sanitized via INJECTION_PATTERNS before the LLM call.' },diff --git a/src/core/ops/files.ts b/src/core/ops/files.tsindex 34369d1368..cf2e44c736 100644--- a/src/core/ops/files.ts+++ b/src/core/ops/files.ts@@ -21,7 +21,7 @@ const file_list: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'List stored files',+ description: 'List files stored in the brain\'s file storage, optionally for one page. Use when finding attachments before file_url. Needs admin scope and the local stdio server.',params: {slug: { type: 'string', description: 'Filter by page slug' },},@@ -48,7 +48,7 @@ const file_upload: Operation = {name: 'file_upload',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Upload a file to storage',+ description: 'Upload a local file into brain storage and attach it to a page. Use when a page needs its source document or image. Needs admin scope and the local stdio server; agent callers may only upload files under the server\'s working directory.',params: {path: { type: 'string', required: true, description: 'Local file path' },page_slug: { type: 'string', description: 'Associate with page' },@@ -159,7 +159,7 @@ const file_url: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'Get a URL for a stored file',+ description: 'Return a URL for a stored file. Use when a user needs to open an attachment listed by file_list. Needs admin scope and the local stdio server. On storage_error: list the files again with file_list.',params: {storage_path: { type: 'string', required: true },},diff --git a/src/core/ops/image.ts b/src/core/ops/image.tsindex 1f0f6b7139..0634be0cd5 100644--- a/src/core/ops/image.ts+++ b/src/core/ops/image.ts@@ -21,10 +21,10 @@ const search_by_image: Operation = {idempotent: true,outputRedaction: 'retrieval',description:- 'v0.36 cross-modal Phase 2: image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL ' ++ 'Image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL ' +'(SSRF-defended). Returns visually-similar image chunks plus any OCR text they carry. Optional `query` text ' +- 'refinement merges via weighted RRF (D13 hybrid intersect). True image→full-text-knowledge requires Phase 3 ' +- '(`gbrain reindex --multimodal` + `search.unified_multimodal: true`).',+ 'refinement merges via weighted RRF. Matching images to full-text knowledge needs multimodal ' ++ 'indexing (`gbrain reindex --multimodal` + `search.unified_multimodal: true`).',params: {image_path: { type: 'string', description: 'Absolute path to image (local CLI callers only — rejected for remote MCP per D18).' },image_url: { type: 'string', description: 'http(s):// URL to image. SSRF-defended; max 3 redirect hops; 10MB cap.' },diff --git a/src/core/ops/ingest-log.ts b/src/core/ops/ingest-log.tsindex b257930369..f1b0b55f1d 100644--- a/src/core/ops/ingest-log.ts+++ b/src/core/ops/ingest-log.ts@@ -16,7 +16,7 @@ const log_ingest: Operation = {name: 'log_ingest',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Log an ingestion event',+ description: 'Record one ingestion event (source type, reference, pages updated, summary) in the brain\'s ingest log. Use after importing or enriching content. Needs write scope.',params: {source_type: { type: 'string', required: true, description: "Kind of ingest source, e.g. 'email', 'meeting', 'rss', 'api'." },source_ref: { type: 'string', required: true, description: 'Identifier of the ingested item — a URL, message id, or file path.' },@@ -47,7 +47,7 @@ const get_ingest_log: Operation = {mutating: false,idempotent: true,outputRedaction: 'retrieval',- description: 'Get recent ingestion log entries',+ description: 'List recent ingestion events (what was imported, from where, which pages changed). Use when checking whether a source was already ingested. Needs read scope.',params: {limit: { type: 'number', description: 'Max entries (default 20)' },},diff --git a/src/core/ops/jobs.ts b/src/core/ops/jobs.tsindex 24a817dbb8..96379a7af0 100644--- a/src/core/ops/jobs.ts+++ b/src/core/ops/jobs.ts@@ -6,6 +6,29 @@ function publicJob(job: MinionJob) {return { ...visible, private_queue_owner_token: job.private_queue_owner_token == null ? null : '[redacted]' };}+/** Fields `list_jobs` may project to (F10 token trim): every public job field. */+const LIST_JOB_FIELDS = [+ 'id', 'name', 'queue', 'status', 'priority', 'data', 'max_attempts', 'attempts_made', 'attempts_started', 'backoff_type',+ 'backoff_delay', 'backoff_jitter', 'stalled_counter', 'max_stalled', 'lock_token', 'lock_until', 'delay_until', 'parent_job_id',+ 'on_child_fail', 'tokens_input', 'tokens_output', 'tokens_cache_read', 'depth', 'max_children', 'timeout_ms', 'timeout_at',+ 'lock_duration_ms', 'remove_on_complete', 'remove_on_fail', 'idempotency_key', 'private_queue_owner_job_id',+ 'private_queue_owner_token', 'private_queue_lease_until', 'quiet_hours', 'stagger_key', 'result', 'progress', 'error_text',+ 'stacktrace', 'created_at', 'started_at', 'finished_at', 'updated_at', 'coalesced',+] as const satisfies readonly (keyof MinionJob)[];++/** Parse list_jobs' `fields` (array or comma string); undefined = every field. */+function parseJobFields(raw: unknown): readonly string[] | undefined {+ if (raw === undefined || raw === null || raw === '') return undefined;+ const list = (Array.isArray(raw) ? raw : String(raw).split(',')).map(f => String(f).trim()).filter(Boolean);+ const valid: ReadonlySet<string> = new Set(LIST_JOB_FIELDS);+ const unknown = list.filter(f => !valid.has(f));+ if (unknown.length > 0) {+ throw opError('invalid_params', `list_jobs: unknown field(s) ${unknown.map(f => JSON.stringify(f.slice(0, 40))).join(', ')}.`,+ `Pass fields from: ${LIST_JOB_FIELDS.join(', ')} (e.g. fields: ["id", "name", "status"]), or omit fields for every field.`);+ }+ return list.length ? list : undefined;+}+/*** Jobs (Minions) operation cluster — pure move from operations.ts (v0.46.x* tranche 2). Op consts stay module-private; `jobsOperations` below lists@@ -16,7 +39,7 @@ function publicJob(job: MinionJob) {*/import type { Operation, OperationContext } from './contract.ts';-import { OperationError } from './contract.ts';+import { OperationError, opError } from './contract.ts';import { hasScope } from '../scope.ts';import {assertEmbedBackfillQueueAdmission,@@ -506,16 +529,18 @@ const list_jobs: Operation = {mutating: false,idempotent: true,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },- description: 'List jobs with optional filters. Agent-scoped tokens (no admin) see only jobs they own.',+ description: 'List background jobs with optional status/queue/name filters; pass fields to project each job to the columns you need. Use when checking queued or failed work. Needs admin scope (agent-scoped tokens see only jobs they own).',params: {status: { type: 'string', description: 'Filter by status (waiting, active, completed, failed, delayed, dead, cancelled)' },queue: { type: 'string', description: 'Filter by queue name' },name: { type: 'string', description: 'Filter by job type' },limit: { type: 'number', description: 'Max results (default: 50)' },+ fields: { type: 'array', items: { type: 'string' }, description: 'Return only these job fields (e.g. ["id","name","status"]) to save tokens; omit for every field.' },},scope: 'admin',agentCallable: true,handler: async (ctx, p) => {+ const fields = parseJobFields(p.fields);const owner = agentOwnerFence(ctx, 'list_jobs');const { MinionQueue } = await import('../minions/queue.ts');const queue = new MinionQueue(ctx.engine);@@ -529,7 +554,8 @@ const list_jobs: Operation = {} as Parameters<typeof queue.getJobs>[0]);// private_queue_owner_token is a capability credential (lease renewal /// attach), not job data — never expose it over MCP envelopes.- return jobs.map(publicJob);+ const visible = jobs.map(publicJob);+ return fields ? visible.map(j => Object.fromEntries(fields.map(f => [f, (j as Record<string, unknown>)[f]]))) : visible;},};@@ -564,7 +590,7 @@ const retry_job: Operation = {name: 'retry_job',idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },- description: 'Re-queue a failed or dead job for retry',+ description: 'Re-queue a failed or dead background job. Use when the cause of the failure is fixed. Needs admin scope. On not_found: list job ids with list_jobs.',params: {id: { type: 'number', required: true, description: 'Job ID' },},@@ -611,7 +637,7 @@ const pause_job: Operation = {name: 'pause_job',idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },- description: 'Pause a waiting, active, or delayed job',+ description: 'Pause a waiting, active or delayed background job. Use when a job must stop without being cancelled. Needs admin scope. On not_found: list job ids with list_jobs.',params: {id: { type: 'number', required: true, description: 'Job ID' },},@@ -631,7 +657,7 @@ const resume_job: Operation = {name: 'resume_job',idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },- description: 'Resume a paused job back to waiting',+ description: 'Resume a paused background job (back to waiting). Use after pause_job once the job may continue. Needs admin scope. On not_found: list job ids with list_jobs.',params: {id: { type: 'number', required: true, description: 'Job ID' },},@@ -678,7 +704,7 @@ const send_job_message: Operation = {name: 'send_job_message',idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },- description: 'Send a sidechannel message to a running job\'s inbox',+ description: 'Send a sidechannel message to a running job\'s inbox (for jobs that read steering messages). Use when steering a long-running agent job. Needs admin scope. On not_found: list job ids with list_jobs.',params: {id: { type: 'number', required: true, description: 'Job ID to message' },payload: { type: 'object', required: true, description: 'Message payload (arbitrary JSON)' },diff --git a/src/core/ops/links.ts b/src/core/ops/links.tsindex d5bc5519f2..943d59af32 100644--- a/src/core/ops/links.ts+++ b/src/core/ops/links.ts@@ -53,7 +53,7 @@ const add_link: Operation = {name: 'add_link',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Create link between pages',+ description: 'Create a typed link (edge) from one page to another in the same source. Use when recording a relationship (works_at, invested_in, mentions). Needs write scope; an explicit link_type must be declared by the active schema pack. On page_not_found: resolve both slugs with resolve_slugs.',params: {from: { type: 'string', required: true, description: "Slug of the page the link originates from (the edge renders on this page), e.g. 'people/alice-example'. These are page slugs — there is no `source`/`target` pair." },to: { type: 'string', required: true, description: "Slug of the page the link points to, e.g. 'companies/acme-example'." },@@ -131,7 +131,7 @@ const remove_link: Operation = {name: 'remove_link',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Remove link between pages',+ description: 'Remove a link between two pages (optionally only one link_type or link_source). Use when a relationship was recorded wrongly. Needs write scope. On page_not_found: resolve both slugs with resolve_slugs.',params: {from: { type: 'string', required: true, description: 'Slug of the page the link originates from (same endpoint order as add_link).' },to: { type: 'string', required: true, description: 'Slug of the page the link points to.' },@@ -309,7 +309,7 @@ const get_links: Operation = {mutating: false,idempotent: true,outputRedaction: 'retrieval',- description: 'List outgoing links from a page',+ description: 'List a page\'s outgoing links (typed edges to other pages). Use when exploring what a page points at; pass source_id or all_sources to widen. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.',params: {slug: { type: 'string', required: true, description: 'Slug of the page whose outgoing links to list.' },source_id: LINK_SOURCE_ID_PARAM,@@ -325,7 +325,7 @@ const get_backlinks: Operation = {mutating: false,idempotent: true,outputRedaction: 'retrieval',- description: 'List incoming links to a page',+ description: 'List a page\'s incoming links (who points at it). Use when finding everything that mentions or relates to an entity. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.',params: {slug: { type: 'string', required: true, description: 'Slug of the page whose incoming links to list.' },source_id: LINK_SOURCE_ID_PARAM,diff --git a/src/core/ops/pages.ts b/src/core/ops/pages.tsindex df9aa07cbf..090dc30669 100644--- a/src/core/ops/pages.ts+++ b/src/core/ops/pages.ts@@ -77,7 +77,7 @@ const get_page: Operation = {name: 'get_page',idempotent: true,outputRedaction: { exempt: 'explicit page read by slug/id; governed by page visibility, not output redaction (CEO-17 raw-read exception)' },- description: 'Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (see v0.26.5 recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).',+ description: 'Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (the soft-delete recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).',params: {slug: { type: 'string', required: true, description: 'Page slug' },fuzzy: { type: 'boolean', description: 'Enable fuzzy slug resolution (default: false)' },@@ -394,7 +394,7 @@ const restore_page: Operation = {name: 'restore_page',idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.26.5 — restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.',+ description: 'Restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.',params: {...PAGE_MUTATION_PARAMS,slug: { type: 'string', required: true, description: "Slug of the soft-deleted page to restore, e.g. 'people/alice-example'." },@@ -421,7 +421,7 @@ const purge_deleted_pages: Operation = {name: 'purge_deleted_pages',idempotent: false,outputRedaction: 'no_stored_text',- description: 'v0.26.5 — admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.',+ description: 'Admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.',params: {older_than_hours: { type: 'number', description: 'Age cutoff in hours. Default 72.' },},diff --git a/src/core/ops/raw-data.ts b/src/core/ops/raw-data.tsindex 1573de94cc..24d36daed6 100644--- a/src/core/ops/raw-data.ts+++ b/src/core/ops/raw-data.ts@@ -15,7 +15,7 @@ const put_raw_data: Operation = {name: 'put_raw_data',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Store raw API response data for a page',+ description: 'Store a raw provider payload (API response JSON) alongside a page, keyed by source. Use when keeping the original data an enrichment came from. Needs write scope. On page_not_found: create or resolve the page first.',params: {slug: { type: 'string', required: true, description: 'Slug of the page to attach the raw data to.' },source: { type: 'string', required: true, description: 'Data source (e.g., crustdata, happenstance)' },diff --git a/src/core/ops/schema-packs.ts b/src/core/ops/schema-packs.tsindex 5f0d4921f2..fdb8f95bac 100644--- a/src/core/ops/schema-packs.ts+++ b/src/core/ops/schema-packs.ts@@ -30,7 +30,7 @@ const get_active_schema_pack: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.',+ description: 'Cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.',params: {},scope: 'read',handler: async (ctx) => {@@ -69,7 +69,7 @@ const list_schema_packs: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: list installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.',+ description: 'List installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.',params: {},scope: 'read',handler: async (_ctx) => {@@ -97,7 +97,7 @@ const schema_stats: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.',+ description: 'Per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.',params: {},scope: 'read',handler: async (ctx) => {@@ -115,7 +115,7 @@ const schema_lint: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.',+ description: 'Lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.',params: {pack: { type: 'string', description: 'Pack name (default: active pack)' },},@@ -170,7 +170,7 @@ const schema_graph: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.',+ description: 'Schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.',params: {},scope: 'read',handler: async (ctx) => {@@ -204,7 +204,7 @@ const schema_explain_type: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.',+ description: 'Resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.',params: {type: { type: 'string', required: true, description: 'Page type name to explain' },},@@ -228,7 +228,7 @@ const schema_review_orphans: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: list pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.',+ description: 'List pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.',params: {limit: { type: 'number', description: 'Max orphans to return (default 100)' },},@@ -252,7 +252,7 @@ const schema_apply_mutations: Operation = {name: 'schema_apply_mutations',idempotent: false,outputRedaction: 'no_stored_text',- description: 'v0.40.7.0: batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.',+ description: 'Batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.',params: {pack: { type: 'string', required: true, description: 'Pack to mutate (must not be bundled)' },mutations: {@@ -323,7 +323,7 @@ const reload_schema_pack: Operation = {name: 'reload_schema_pack',idempotent: true,outputRedaction: 'no_stored_text',- description: 'v0.40.6.0: flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through extends-chain (codex C6). Admin scope; NOT localOnly. Returns {invalidated: string[]}.',+ description: 'Flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through the extends chain. Admin scope; NOT localOnly. Returns {invalidated: string[]}.',params: {pack: { type: 'string', description: 'Pack name to invalidate (omit to flush all)' },},diff --git a/src/core/ops/sources.ts b/src/core/ops/sources.tsindex f2dc8d5720..e020f81769 100644--- a/src/core/ops/sources.ts+++ b/src/core/ops/sources.ts@@ -25,7 +25,7 @@ const whoami: Operation = {'{transport: "local", scopes: []}, or {transport: "stdio", scopes: []} ' +'for the auth-less stdio MCP pipe. Throws unknown_transport when the ' +'context is ambiguous (remote=true without auth and no transport marker) ' +- '— fail-closed posture mirroring the v0.26.9 trust-boundary contract.',+ '(fail-closed). Every shape also carries `readiness` (the setup gaps of this install, each with its fix); stdio scopes are the grant of the verified registration.',params: {},scope: 'read',handler: async (ctx) => {@@ -90,8 +90,8 @@ const sources_add: Operation = {idempotent: false,outputRedaction: 'no_stored_text',description:- 'Register a new source. Supports either --path (existing v0.17 behavior) ' +- 'or --url (v0.28 federated remote-clone path: parses the URL through the ' ++ 'Register a new source. Supports either path (a local directory) ' ++ 'or url (a remote clone: parses the URL through the ' +'SSRF gate, clones into $GBRAIN_HOME/clones/<id>/ via temp-dir + rename ' +'atomicity, and stores remote_url in sources.config). Pre-flight collision ' +'check on id; rollback on either-side failure.',@@ -175,11 +175,11 @@ const sources_list: Operation = {idempotent: true,outputRedaction: 'no_stored_text',description:- 'List registered sources with page counts and remote_url. v0.28 surfaces ' +- 'the new remote_url field so a remote MCP caller can confirm a source is ' ++ 'List registered sources with page counts and remote_url. remote_url lets ' ++ 'a remote MCP caller confirm a source is ' +'managed by clone+pull rather than user-supplied path. Results are ' +"confined to the caller's resolved source scope (federated read grant > " +- 'bound source; #4433) and carry no marker when rows were withheld, so a ' ++ 'bound source) and carry no marker when rows were withheld, so a ' +'listing may be incomplete. Only the trusted local CLI (`gbrain sources ' +'list`) sees the full registry.',params: {@@ -271,7 +271,7 @@ const sources_status: Operation = {'"not-a-dir" | "no-git" | "url-drift" | "corrupted" | "not-applicable") ' +'so a remote MCP caller can diagnose whether the on-disk clone is ' +"syncable without SSH access to the brain host. Confined to the caller's " +- 'resolved source scope (#4433); an out-of-scope id answers not_found, ' ++ 'resolved source scope; an out-of-scope id answers not_found, ' +'indistinguishable from a nonexistent source.',params: {id: { type: 'string', required: true, description: "Source id to diagnose, as listed by sources_list (e.g. 'wiki'). A source id, not a page slug." },diff --git a/src/core/ops/sync-status.ts b/src/core/ops/sync-status.tsindex c9eaec37ab..96028319c0 100644--- a/src/core/ops/sync-status.ts+++ b/src/core/ops/sync-status.ts@@ -14,7 +14,7 @@ const sync_brain: Operation = {name: 'sync_brain',idempotent: false,outputRedaction: 'no_stored_text',- description: 'Sync git repo to brain (incremental)',+ description: 'Pull and import changes from a source\'s git repository (incremental; dry_run previews). Use when files changed on disk or upstream. Needs admin scope and the local stdio server. On a missing local_path: the error names the sources add command.',params: {repo: { type: 'string', description: 'Path to git repo (optional if configured)' },source_id: { type: 'string', description: 'Explicit source to sync (wins over repo-derived and ambient routing)' },diff --git a/src/core/ops/tags.ts b/src/core/ops/tags.tsindex 6af46219e4..4e356e52b3 100644--- a/src/core/ops/tags.ts+++ b/src/core/ops/tags.ts@@ -16,7 +16,7 @@ const add_tag: Operation = {name: 'add_tag',idempotent: true,outputRedaction: 'no_stored_text',- description: 'Add tag to page',+ description: 'Add one tag to a page (idempotent). Use when filing or grouping pages for later get_tags / list_pages tag filters. Needs write scope. On page_not_found: resolve the slug with resolve_slugs, then call again.',params: {request_id: WRITE_REQUEST_PARAM,slug: { type: 'string', required: true, description: "Slug of the page to tag, e.g. 'people/alice-example'." },@@ -37,7 +37,7 @@ const remove_tag: Operation = {name: 'remove_tag',idempotent: true,outputRedaction: 'no_stored_text',- description: 'Remove tag from page',+ description: 'Remove one tag from a page. Use when a tag was wrong or no longer applies. Needs write scope. On page_not_found: resolve the slug with resolve_slugs, then call again.',params: {request_id: WRITE_REQUEST_PARAM,slug: { type: 'string', required: true, description: 'Slug of the page to untag.' },@@ -58,7 +58,7 @@ const get_tags: Operation = {mutating: false,idempotent: true,outputRedaction: 'no_stored_text',- description: 'List tags for a page',+ description: 'List the tags on one page. Use when checking how a page is filed before adding or removing tags. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.',params: {slug: { type: 'string', required: true, description: 'Slug of the page whose tags to list.' },},diff --git a/src/core/ops/takes.ts b/src/core/ops/takes.tsindex 721fb70683..45a71f9e47 100644--- a/src/core/ops/takes.ts+++ b/src/core/ops/takes.ts@@ -200,7 +200,7 @@ const think: Operation = {name: 'think',idempotent: false,outputRedaction: 'retrieval',- description: 'Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis.',+ description: 'Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis. Needs a chat-model API key (Anthropic or OpenAI) for the synthesized answer, a paid call; a keyless brain returns the gathered evidence only (a synthesis_keyless notice explains). save/take persist for the local CLI only.',scope: 'read',params: {question: { type: 'string', required: true, description: 'The question to think about' },diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 8772502d5f..0aa696d18d 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -456,7 +456,7 @@ export function unknownToolEnvelope(name: string, opts: DispatchOpts, legacyErro.filter(op => !op.localOnly && !op.publishGateKey && (allowedOps ? allowedOps.has(op.name) : true)).map(op => op.name);const nearest = suggestNearest(name, candidates);- const hint = hiddenToolHint(name, opts); // F6: owner's stdio pipe only+ const hint = hiddenToolHint(operations.find(o => o.name === name), opts); // F6: owner's stdio pipe onlyconst suggestion = hint?.suggestion ?? (nearest? `Did you mean "${nearest}"?`: 'List the tools this connection can call (tools/list) and use one of those names.');diff --git a/src/mcp/hidden-tool-hint.ts b/src/mcp/hidden-tool-hint.tsindex 5d392e415d..6f3adb1285 100644--- a/src/mcp/hidden-tool-hint.ts+++ b/src/mcp/hidden-tool-hint.ts@@ -6,14 +6,13 @@* an existence oracle; HTTP keeps the opaque unknown_tool envelope.*/import type { Action } from '../core/agent-output.ts';-import { operations } from '../core/operations.ts';+import type { Operation } from '../core/operations.ts';import { cliEquivalent } from '../core/ops/cli-equivalent.ts';-export function hiddenToolHint(name: string, opts: { transport?: string; remote?: boolean; surface?: string; allowedOps?: ReadonlySet<string> }):+export function hiddenToolHint(op: Operation | undefined, opts: { transport?: string; remote?: boolean; surface?: string; allowedOps?: ReadonlySet<string> }):{ suggestion: string; fix: Action } | null {- if (opts.transport !== 'stdio' || opts.remote === false || !opts.allowedOps || opts.allowedOps.has(name)) return null;- const op = operations.find(o => o.name === name);- if (!op || op.localOnly) return null;+ if (!op || op.localOnly || opts.transport !== 'stdio' || opts.remote === false || !opts.allowedOps || opts.allowedOps.has(op.name)) return null;+ const name = op.name;const argv = cliEquivalent(op);const surface = opts.surface ?? 'full';const why = surface === 'full'diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.jsonindex 4febe12d9f..8e35312552 100644--- a/test/fixtures/goldens/cli/help-and-errors.json+++ b/test/fixtures/goldens/cli/help-and-errors.json@@ -671,7 +671,7 @@"stdout": ["Usage: gbrain query <query> [options]","",- "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.",+ "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged. Needs an embedding key for semantic recall and a chat-model key for expansion; without them it runs keyword-only and a degraded_recall notice says so (a thin result is then not proof of absence).","","Options:"," <query> Question or topic text for hybrid retrieval with expansion (e.g. 'agents that do web research'). This is the search text param — there is no `text` or `q` param. Optional ONLY because `image` is the alternative entry point; a call with neither fails with invalid_params.",@@ -734,7 +734,7 @@"stdout": ["Usage: gbrain link-add <from> <to> [options]","",- "Create link between pages",+ "Create a typed link (edge) from one page to another in the same source. Use when recording a relationship (works_at, invested_in, mentions). Needs write scope; an explicit link_type must be declared by the active schema pack. On page_not_found: resolve both slugs with resolve_slugs.","","Options:"," <from> Slug of the page the link originates from (the edge renders on this page), e.g. 'people/alice-example'. These are page slugs — there is no `source`/`target` pair. (required)",diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.jsonindex 9481bad1c9..45cd524c4e 100644--- a/test/fixtures/goldens/cli/tools-json.json+++ b/test/fixtures/goldens/cli/tools-json.json@@ -2,8 +2,8 @@"golden": {"exitCode": 0,"stderr": "",- "stdoutBytes": 229964,- "stdoutSha256": "dd329e72404ba7ca00c57ed651b3e48c3ac470a9b160cf1333f6c2b338a14e5e",+ "stdoutBytes": 234048,+ "stdoutSha256": "8e3d89827ff4164242aa14101563639a97110a9fd51ee02caf44214acb82fd58","toolNames": ["remember","entity",@@ -342,7 +342,7 @@"scope": "write"},{- "description": "Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (see v0.26.5 recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).",+ "description": "Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (the soft-delete recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).","idempotent": true,"local_only": false,"mutating": false,@@ -578,7 +578,7 @@"scope": "read"},{- "description": "v0.26.5 — restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.",+ "description": "Restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.","idempotent": true,"local_only": false,"mutating": true,@@ -622,7 +622,7 @@"scope": "write"},{- "description": "v0.26.5 — admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.",+ "description": "Admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.","idempotent": false,"local_only": true,"mutating": true,@@ -996,7 +996,7 @@"scope": "read"},{- "description": "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.",+ "description": "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience or find_anomalies (raw transcripts are owner-only: `gbrain transcripts recent` on the brain host). Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged. Needs an embedding key for semantic recall and a chat-model key for expansion; without them it runs keyword-only and a degraded_recall notice says so (a thin result is then not proof of absence).","idempotent": true,"local_only": false,"mutating": false,@@ -1300,7 +1300,7 @@"scope": "admin"},{- "description": "v0.36 cross-modal Phase 2: image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL (SSRF-defended). Returns visually-similar image chunks plus any OCR text they carry. Optional `query` text refinement merges via weighted RRF (D13 hybrid intersect). True image→full-text-knowledge requires Phase 3 (`gbrain reindex --multimodal` + `search.unified_multimodal: true`).",+ "description": "Image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL (SSRF-defended). Returns visually-similar image chunks plus any OCR text they carry. Optional `query` text refinement merges via weighted RRF. Matching images to full-text knowledge needs multimodal indexing (`gbrain reindex --multimodal` + `search.unified_multimodal: true`).","idempotent": true,"local_only": false,"mutating": false,@@ -1357,7 +1357,7 @@"scope": "read"},{- "description": "Add tag to page",+ "description": "Add one tag to a page (idempotent). Use when filing or grouping pages for later get_tags / list_pages tag filters. Needs write scope. On page_not_found: resolve the slug with resolve_slugs, then call again.","idempotent": true,"local_only": false,"mutating": true,@@ -1392,7 +1392,7 @@"scope": "write"},{- "description": "Remove tag from page",+ "description": "Remove one tag from a page. Use when a tag was wrong or no longer applies. Needs write scope. On page_not_found: resolve the slug with resolve_slugs, then call again.","idempotent": true,"local_only": false,"mutating": true,@@ -1427,7 +1427,7 @@"scope": "write"},{- "description": "List tags for a page",+ "description": "List the tags on one page. Use when checking how a page is filed before adding or removing tags. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.","idempotent": true,"local_only": false,"mutating": false,@@ -1451,7 +1451,7 @@"scope": "read"},{- "description": "Create link between pages",+ "description": "Create a typed link (edge) from one page to another in the same source. Use when recording a relationship (works_at, invested_in, mentions). Needs write scope; an explicit link_type must be declared by the active schema pack. On page_not_found: resolve both slugs with resolve_slugs.","idempotent": false,"local_only": false,"mutating": true,@@ -1496,7 +1496,7 @@"scope": "write"},{- "description": "Remove link between pages",+ "description": "Remove a link between two pages (optionally only one link_type or link_source). Use when a relationship was recorded wrongly. Needs write scope. On page_not_found: resolve both slugs with resolve_slugs.","idempotent": false,"local_only": false,"mutating": true,@@ -1536,7 +1536,7 @@"scope": "write"},{- "description": "List outgoing links from a page",+ "description": "List a page's outgoing links (typed edges to other pages). Use when exploring what a page points at; pass source_id or all_sources to widen. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.","idempotent": true,"local_only": false,"mutating": false,@@ -1570,7 +1570,7 @@"scope": "read"},{- "description": "List incoming links to a page",+ "description": "List a page's incoming links (who points at it). Use when finding everything that mentions or relates to an entity. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.","idempotent": true,"local_only": false,"mutating": false,@@ -1842,7 +1842,7 @@"scope": "read"},{- "description": "Revert page to a previous version",+ "description": "Restore a page to an earlier version from its history (a new revision; history is kept). Use when an edit must be undone. Needs write scope. On a revision conflict: re-read the page with get_page and resubmit with its revision.","idempotent": true,"local_only": false,"mutating": true,@@ -2680,7 +2680,7 @@"scope": "read"},{- "description": "Sync git repo to brain (incremental)",+ "description": "Pull and import changes from a source's git repository (incremental; dry_run previews). Use when files changed on disk or upstream. Needs admin scope and the local stdio server. On a missing local_path: the error names the sources add command.","idempotent": false,"local_only": true,"mutating": true,@@ -2727,7 +2727,7 @@"scope": "admin"},{- "description": "Store raw API response data for a page",+ "description": "Store a raw provider payload (API response JSON) alongside a page, keyed by source. Use when keeping the original data an enrichment came from. Needs write scope. On page_not_found: create or resolve the page first.","idempotent": false,"local_only": false,"mutating": true,@@ -2792,7 +2792,7 @@"scope": "read"},{- "description": "Fuzzy-resolve a partial slug to matching page slugs",+ "description": "Fuzzy-match a partial name or slug to existing page slugs. Use when a slug is uncertain before get_page, links or tags. Needs read scope. On no matches: search for the name instead.","idempotent": true,"local_only": false,"mutating": false,@@ -2821,7 +2821,7 @@"scope": "read"},{- "description": "Get content chunks for a page",+ "description": "Return a page's indexed content chunks (the units search ranks). Use when debugging why search did or did not match a page. Needs read scope. On page_not_found: resolve the slug with resolve_slugs.","idempotent": true,"local_only": false,"mutating": false,@@ -2845,7 +2845,7 @@"scope": "read"},{- "description": "Log an ingestion event",+ "description": "Record one ingestion event (source type, reference, pages updated, summary) in the brain's ingest log. Use after importing or enriching content. Needs write scope.","idempotent": false,"local_only": false,"mutating": true,@@ -2890,7 +2890,7 @@"scope": "write"},{- "description": "Get recent ingestion log entries",+ "description": "List recent ingestion events (what was imported, from where, which pages changed). Use when checking whether a source was already ingested. Needs read scope.","idempotent": true,"local_only": false,"mutating": false,@@ -2934,7 +2934,7 @@"scope": "admin"},{- "description": "List stored files",+ "description": "List files stored in the brain's file storage, optionally for one page. Use when finding attachments before file_url. Needs admin scope and the local stdio server.","idempotent": true,"local_only": true,"mutating": false,@@ -2956,7 +2956,7 @@"scope": "admin"},{- "description": "Upload a file to storage",+ "description": "Upload a local file into brain storage and attach it to a page. Use when a page needs its source document or image. Needs admin scope and the local stdio server; agent callers may only upload files under the server's working directory.","idempotent": false,"local_only": true,"mutating": true,@@ -2985,7 +2985,7 @@"scope": "admin"},{- "description": "Get a URL for a stored file",+ "description": "Return a URL for a stored file. Use when a user needs to open an attachment listed by file_list. Needs admin scope and the local stdio server. On storage_error: list the files again with file_list.","idempotent": true,"local_only": true,"mutating": false,@@ -3091,12 +3091,13 @@"scope": "admin"},{- "description": "List jobs with optional filters. Agent-scoped tokens (no admin) see only jobs they own.",+ "description": "List background jobs with optional status/queue/name filters; pass fields to project each job to the columns you need. Use when checking queued or failed work. Needs admin scope (agent-scoped tokens see only jobs they own).","idempotent": true,"local_only": false,"mutating": false,"name": "list_jobs","parameters": {+ "fields": "array?","limit": "number?","name": "string?","queue": "string?",@@ -3105,6 +3106,13 @@"required_scopes": [],"schema": {"properties": {+ "fields": {+ "description": "Return only these job fields (e.g. [\"id\",\"name\",\"status\"]) to save tokens; omit for every field.",+ "items": {+ "type": "string"+ },+ "type": "array"+ },"limit": {"description": "Max results (default: 50)","type": "number"@@ -3152,7 +3160,7 @@"scope": "admin"},{- "description": "Re-queue a failed or dead job for retry",+ "description": "Re-queue a failed or dead background job. Use when the cause of the failure is fixed. Needs admin scope. On not_found: list job ids with list_jobs.","idempotent": false,"local_only": false,"mutating": true,@@ -3200,7 +3208,7 @@"scope": "admin"},{- "description": "Pause a waiting, active, or delayed job",+ "description": "Pause a waiting, active or delayed background job. Use when a job must stop without being cancelled. Needs admin scope. On not_found: list job ids with list_jobs.","idempotent": false,"local_only": false,"mutating": true,@@ -3224,7 +3232,7 @@"scope": "admin"},{- "description": "Resume a paused job back to waiting",+ "description": "Resume a paused background job (back to waiting). Use after pause_job once the job may continue. Needs admin scope. On not_found: list job ids with list_jobs.","idempotent": false,"local_only": false,"mutating": true,@@ -3277,7 +3285,7 @@"scope": "admin"},{- "description": "Send a sidechannel message to a running job's inbox",+ "description": "Send a sidechannel message to a running job's inbox (for jobs that read steering messages). Use when steering a long-running agent job. Needs admin scope. On not_found: list job ids with list_jobs.","idempotent": false,"local_only": false,"mutating": true,@@ -3573,7 +3581,7 @@"scope": "read"},{- "description": "Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis.",+ "description": "Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis. Needs a chat-model API key (Anthropic or OpenAI) for the synthesized answer, a paid call; a keyless brain returns the gathered evidence only (a synthesis_keyless notice explains). save/take persist for the local CLI only.","idempotent": false,"local_only": false,"mutating": true,@@ -3973,7 +3981,7 @@"scope": "write"},{- "description": "Introspect the calling identity. Returns one of three transport shapes: {transport: \"oauth\", client_id, client_name, scopes, expires_at, source_id, federated_read}, {transport: \"legacy\", token_name, scopes, expires_at: null}, or {transport: \"local\", scopes: []}, or {transport: \"stdio\", scopes: []} for the auth-less stdio MCP pipe. Throws unknown_transport when the context is ambiguous (remote=true without auth and no transport marker) — fail-closed posture mirroring the v0.26.9 trust-boundary contract.",+ "description": "Introspect the calling identity. Returns one of three transport shapes: {transport: \"oauth\", client_id, client_name, scopes, expires_at, source_id, federated_read}, {transport: \"legacy\", token_name, scopes, expires_at: null}, or {transport: \"local\", scopes: []}, or {transport: \"stdio\", scopes: []} for the auth-less stdio MCP pipe. Throws unknown_transport when the context is ambiguous (remote=true without auth and no transport marker) (fail-closed). Every shape also carries `readiness` (the setup gaps of this install, each with its fix); stdio scopes are the grant of the verified registration.","idempotent": true,"local_only": false,"mutating": false,@@ -3988,7 +3996,7 @@"scope": "read"},{- "description": "Register a new source. Supports either --path (existing v0.17 behavior) or --url (v0.28 federated remote-clone path: parses the URL through the SSRF gate, clones into $GBRAIN_HOME/clones/<id>/ via temp-dir + rename atomicity, and stores remote_url in sources.config). Pre-flight collision check on id; rollback on either-side failure.",+ "description": "Register a new source. Supports either path (a local directory) or url (a remote clone: parses the URL through the SSRF gate, clones into $GBRAIN_HOME/clones/<id>/ via temp-dir + rename atomicity, and stores remote_url in sources.config). Pre-flight collision check on id; rollback on either-side failure.","idempotent": false,"local_only": false,"mutating": true,@@ -4037,7 +4045,7 @@"scope": "sources_admin"},{- "description": "List registered sources with page counts and remote_url. v0.28 surfaces the new remote_url field so a remote MCP caller can confirm a source is managed by clone+pull rather than user-supplied path. Results are confined to the caller's resolved source scope (federated read grant > bound source; #4433) and carry no marker when rows were withheld, so a listing may be incomplete. Only the trusted local CLI (`gbrain sources list`) sees the full registry.",+ "description": "List registered sources with page counts and remote_url. remote_url lets a remote MCP caller confirm a source is managed by clone+pull rather than user-supplied path. Results are confined to the caller's resolved source scope (federated read grant > bound source) and carry no marker when rows were withheld, so a listing may be incomplete. Only the trusted local CLI (`gbrain sources list`) sees the full registry.","idempotent": true,"local_only": false,"mutating": false,@@ -4098,7 +4106,7 @@"scope": "sources_admin"},{- "description": "Per-source diagnostic. Returns clone_state (\"healthy\" | \"missing\" | \"not-a-dir\" | \"no-git\" | \"url-drift\" | \"corrupted\" | \"not-applicable\") so a remote MCP caller can diagnose whether the on-disk clone is syncable without SSH access to the brain host. Confined to the caller's resolved source scope (#4433); an out-of-scope id answers not_found, indistinguishable from a nonexistent source.",+ "description": "Per-source diagnostic. Returns clone_state (\"healthy\" | \"missing\" | \"not-a-dir\" | \"no-git\" | \"url-drift\" | \"corrupted\" | \"not-applicable\") so a remote MCP caller can diagnose whether the on-disk clone is syncable without SSH access to the brain host. Confined to the caller's resolved source scope; an out-of-scope id answers not_found, indistinguishable from a nonexistent source.","idempotent": true,"local_only": false,"mutating": false,@@ -4962,7 +4970,7 @@"scope": "read"},{- "description": "v0.31: extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: \"private\"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).",+ "description": "Extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: \"private\"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).","idempotent": true,"local_only": false,"mutating": true,@@ -5316,7 +5324,7 @@"scope": "read"},{- "description": "v0.35.4 — return the chronological claim trajectory for an entity (typed metric values over time, plus auto-detected regressions and narrative drift). Use this when the user asks 'how has Acme's MRR trended', 'show me what alice-example said about runway over time', 'is this founder consistent', 'find regressions for fund-a's portfolio', or wants a time-series view of an entity's structured claims. Returns `{points: [{fact_id, valid_from, metric, value, unit, period, text, source_session, source_markdown_slug}], regressions: [{metric, from_value, from_date, to_value, to_date, delta_pct}], drift_score: number|null, schema_version: 1}`. Drift score 0 = stable narrative, 1 = every consecutive claim is unrelated; null when fewer than 3 typed points exist. Visibility-filtered for remote callers (world-only); source-scoped by the caller's OAuth source binding. Pair with `gbrain founder scorecard <slug>` for an aggregated rollup of the same data.",+ "description": "Return the chronological claim trajectory for an entity (typed metric values over time, plus auto-detected regressions and narrative drift). Use this when the user asks 'how has Acme's MRR trended', 'show me what alice-example said about runway over time', 'is this founder consistent', 'find regressions for fund-a's portfolio', or wants a time-series view of an entity's structured claims. Returns `{points: [{fact_id, valid_from, metric, value, unit, period, text, source_session, source_markdown_slug}], regressions: [{metric, from_value, from_date, to_value, to_date, delta_pct}], drift_score: number|null, schema_version: 1}`. Drift score 0 = stable narrative, 1 = every consecutive claim is unrelated; null when fewer than 3 typed points exist. Visibility-filtered for remote callers (world-only); source-scoped by the caller's OAuth source binding. Pair with `gbrain founder scorecard <slug>` for an aggregated rollup of the same data.","idempotent": true,"local_only": false,"mutating": false,@@ -5368,7 +5376,7 @@"scope": "read"},{- "description": "BEFORE editing any function, run code_callers with the symbol name to find every caller (the people who'd be affected by your change). Returns direct callers from the v0.20+ tree-sitter call graph. Use during plan-mode to size the change. Defaults to source-scoped; for multi-source brains pass source_id or all_sources=true. Returns: `{symbol, count, callers: [{from_symbol_qualified, to_symbol_qualified, edge_type, resolved}]}`. Example: `{symbol:'parseMarkdown', count:4, callers:[{from_symbol_qualified:'callerInA', to_symbol_qualified:'parseMarkdown', edge_type:'calls', resolved:true}]}`. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "description": "BEFORE editing any function, run code_callers with the symbol name to find every caller (the people who'd be affected by your change). Returns direct callers from the tree-sitter call graph. Use during plan-mode to size the change. Defaults to source-scoped; for multi-source brains pass source_id or all_sources=true. Returns: `{symbol, count, callers: [{from_symbol_qualified, to_symbol_qualified, edge_type, resolved}]}`. Example: `{symbol:'parseMarkdown', count:4, callers:[{from_symbol_qualified:'callerInA', to_symbol_qualified:'parseMarkdown', edge_type:'calls', resolved:true}]}`. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.","idempotent": true,"local_only": false,"mutating": false,@@ -5602,7 +5610,7 @@"scope": "read"},{- "description": "Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (D8 destructive-guard).",+ "description": "Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (destructive: it is guarded).","idempotent": true,"local_only": true,"mutating": true,@@ -5629,7 +5637,7 @@"scope": "admin"},{- "description": "Re-embed the brain onto a different embedding provider/model (#3390): schema dimension transition, NULL-signature (#3391) invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.",+ "description": "Re-embed the brain onto a different embedding provider/model: schema dimension transition, NULL-signature invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.","idempotent": false,"local_only": true,"mutating": true,@@ -5683,7 +5691,7 @@"scope": "admin"},{- "description": "v0.40.6.0: cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.",+ "description": "Cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.","idempotent": true,"local_only": false,"mutating": false,@@ -5698,7 +5706,7 @@"scope": "read"},{- "description": "v0.40.6.0: list installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.",+ "description": "List installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.","idempotent": true,"local_only": false,"mutating": false,@@ -5713,7 +5721,7 @@"scope": "read"},{- "description": "v0.40.6.0: per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.",+ "description": "Per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.","idempotent": true,"local_only": false,"mutating": false,@@ -5728,7 +5736,7 @@"scope": "read"},{- "description": "v0.40.6.0: lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.",+ "description": "Lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.","idempotent": true,"local_only": false,"mutating": false,@@ -5750,7 +5758,7 @@"scope": "read"},{- "description": "v0.40.6.0: schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.",+ "description": "Schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.","idempotent": true,"local_only": false,"mutating": false,@@ -5765,7 +5773,7 @@"scope": "read"},{- "description": "v0.40.6.0: resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.",+ "description": "Resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.","idempotent": true,"local_only": false,"mutating": false,@@ -5789,7 +5797,7 @@"scope": "read"},{- "description": "v0.40.6.0: list pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.",+ "description": "List pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.","idempotent": true,"local_only": false,"mutating": false,@@ -5811,7 +5819,7 @@"scope": "read"},{- "description": "v0.40.7.0: batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.",+ "description": "Batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.","idempotent": false,"local_only": false,"mutating": true,@@ -5849,7 +5857,7 @@"scope": "admin"},{- "description": "v0.40.6.0: flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through extends-chain (codex C6). Admin scope; NOT localOnly. Returns {invalidated: string[]}.",+ "description": "Flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through the extends chain. Admin scope; NOT localOnly. Returns {invalidated: string[]}.","idempotent": true,"local_only": false,"mutating": false,diff --git a/test/tool-descriptions.test.ts b/test/tool-descriptions.test.tsnew file mode 100644index 0000000000..8ee8abe984--- /dev/null+++ b/test/tool-descriptions.test.ts@@ -0,0 +1,73 @@+/**+ * F10 (agent operator contract v1): tool descriptions follow the template+ * `<what>. Use when <…>. Needs <key/scope>. On <error>: <next>.`, carry no+ * release prefixes or ticket jargon, and query/think state their key+ * dependence; list_jobs can project fields to save tokens.+ */+import { describe, test, expect, beforeAll, afterAll, beforeEach } from 'bun:test';+import { operations, operationsByName, type OperationContext } from '../src/core/operations.ts';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { MinionQueue } from '../src/core/minions/queue.ts';++const JARGON = /\bv\d+\.\d+|#\d{3,}|\bWP\d|\bD\d+\b|\bCX\d|\bENG-|amendment \d|codex [A-Z]\d/i;++describe('tool descriptions (F10)', () => {+ test('every description is at least 60 characters', () => {+ const short = operations.filter(op => (op.description ?? '').length < 60).map(op => op.name);+ expect(short).toEqual([]);+ });++ test('no release prefixes or ticket jargon', () => {+ const jargon = operations.filter(op => JARGON.test(op.description ?? '')).map(op => `${op.name}: ${op.description.match(JARGON)![0]}`);+ expect(jargon).toEqual([]);+ });++ test('query and think state their key dependence', () => {+ expect(operationsByName['query'].description).toContain('Needs an embedding key');+ expect(operationsByName['query'].description).toContain('keyword-only');+ expect(operationsByName['think'].description).toContain('Needs a chat-model API key (Anthropic or OpenAI)');+ expect(operationsByName['think'].description).toContain('keyless brain returns the gathered evidence');+ });++ test('rewritten short descriptions follow the template', () => {+ for (const name of ['add_tag', 'get_links', 'retry_job', 'resolve_slugs', 'file_url']) {+ const d = operationsByName[name].description;+ expect(d).toMatch(/\. Use when /);+ expect(d).toMatch(/Needs [a-z]+ scope/);+ }+ });+});++describe('list_jobs fields projection (F10 token trim)', () => {+ let engine: PGLiteEngine;+ let queue: MinionQueue;+ beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({ database_url: '' });+ await engine.initSchema();+ queue = new MinionQueue(engine);+ }, 60_000);+ afterAll(async () => { await engine.disconnect(); });+ beforeEach(async () => { await engine.executeRaw('DELETE FROM minion_jobs'); });++ const list_jobs = operationsByName['list_jobs']!;+ const local = () => ({ engine, config: {}, logger: console, dryRun: false, remote: false, sourceId: 'default' }) as unknown as OperationContext;++ test('fields projects each job; omitted keeps every field; unknown names list the valid ones', async () => {+ await queue.add('subagent', { prompt: 'fields-1' }, { queue: 'default' }, { allowProtectedSubmit: true });+ const full = await list_jobs.handler(local(), {}) as Array<Record<string, unknown>>;+ expect(Object.keys(full[0])).toContain('data');+ const slim = await list_jobs.handler(local(), { fields: ['id', 'name', 'status'] }) as Array<Record<string, unknown>>;+ expect(Object.keys(slim[0]).sort()).toEqual(['id', 'name', 'status']);+ const csv = await list_jobs.handler(local(), { fields: 'id,status' }) as Array<Record<string, unknown>>;+ expect(Object.keys(csv[0]).sort()).toEqual(['id', 'status']);+ await expect(list_jobs.handler(local(), { fields: ['id', 'secret_sauce'] })).rejects.toMatchObject({+ code: 'invalid_params',+ suggestion: expect.stringContaining('Pass fields from: id, name'),+ });+ // Never a way around publicJob: the authority is not projectable, the owner token stays redacted.+ await expect(list_jobs.handler(local(), { fields: ['submission_authority'] })).rejects.toMatchObject({ code: 'invalid_params' });+ const tok = await list_jobs.handler(local(), { fields: ['private_queue_owner_token'] }) as Array<Record<string, unknown>>;+ expect([null, '[redacted]']).toContain(tok[0].private_queue_owner_token as string | null);+ });+});