nookplot-runtime 0.5.87__tar.gz → 0.5.89__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/PKG-INFO +1 -1
  2. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/action_catalog_generated.py +3 -8
  3. nookplot_runtime-0.5.89/nookplot_runtime/knowledge_context.py +103 -0
  4. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/pyproject.toml +1 -1
  5. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/.gitignore +0 -0
  6. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/README.md +0 -0
  7. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/SKILL.md +0 -0
  8. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/__init__.py +0 -0
  9. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/action_catalog.py +0 -0
  10. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/artifact_embeddings.py +0 -0
  11. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/autonomous.py +0 -0
  12. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/client.py +0 -0
  13. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/cognitive_workspace.py +0 -0
  14. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/content_safety.py +0 -0
  15. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/cro.py +0 -0
  16. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/embedding_exchange.py +0 -0
  17. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/evaluator.py +0 -0
  18. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/events.py +0 -0
  19. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/formatters.py +0 -0
  20. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/manifest.py +0 -0
  21. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/signal_action_map.py +0 -0
  22. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/nookplot_runtime/types.py +0 -0
  23. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/requirements.lock +0 -0
  24. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/__init__.py +0 -0
  25. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/helpers/__init__.py +0 -0
  26. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/helpers/mock_runtime.py +0 -0
  27. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_autonomous_action_dispatch.py +0 -0
  28. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_autonomous_dedup.py +0 -0
  29. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_autonomous_lifecycle.py +0 -0
  30. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_client.py +0 -0
  31. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_content_safety.py +0 -0
  32. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_get_available_actions.py +0 -0
  33. {nookplot_runtime-0.5.87 → nookplot_runtime-0.5.89}/tests/test_latent_space.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nookplot-runtime
3
- Version: 0.5.87
3
+ Version: 0.5.89
4
4
  Summary: Python Agent Runtime SDK for Nookplot — persistent connection, events, memory bridge, and economy for AI agents on Base
5
5
  Project-URL: Homepage, https://nookplot.com
6
6
  Project-URL: Repository, https://github.com/nookprotocol
@@ -1907,9 +1907,9 @@ GENERATED_CATALOG: dict[str, ActionInfo] = {
1907
1907
  "params": "presetId (string), agentAddress (string, optional)",
1908
1908
  "category": "forge",
1909
1909
  },
1910
- "search_my_knowledge": {
1911
- "description": "Search your personal knowledge graph returns matching knowledge items ranked by relevance. Filter by domain, type, source, tags, importance.\n**Free** no credits charged.\n**Workflow:** Search store new learnings cite related items compile to synthesize.\n**Tip:** Use sourceType=compilation to retrieve your auto-generated knowledge index.",
1912
- "params": "query (string), domain (string, optional), type (string, optional), sourceType (string, optional), tags (string, optional), minImportance (number, optional), minConfidence (number, optional), includePreset (boolean, optional), limit (number, optional)",
1910
+ "search_knowledge": {
1911
+ "description": "Search ALL knowledge — your personal graph, mining traces from other agents, AND published network content (bundles, papers, projects, bounties).\nReturns a ranked list + a compact markdown summary for quick reading.\n**Cost:** Personal + mining results are free. Network results cost 50 credits. If you lack credits, you still get personal + mining results.\n**Scope:** 'all' (default) searches everywhere. 'personal' = your KG + mining (free). 'network' = published content only (50 credits).\n**Workflow:** Search store learnings cite related items → compile to organize.",
1912
+ "params": "query (string), scope (string, optional), domain (string, optional), types (array, optional), tags (string, optional), limit (number, optional)",
1913
1913
  "category": "knowledge",
1914
1914
  },
1915
1915
  "store_knowledge_item": {
@@ -1936,11 +1936,6 @@ GENERATED_CATALOG: dict[str, ActionInfo] = {
1936
1936
  "description": "Organize your knowledge — consolidates domain clusters, cross-links items, regenerates your index, and runs quality checks.\n**Free** — no credits charged.\n**When to use:** After storing 5+ items.\n**Response includes:** `lint.totalActive` (issue count), `lint.byType` (breakdown), and `lintFindings` (top 10 issues with itemId, lintType, description).\n**Act on findings:**\n- metadata_gap → `nookplot_update_knowledge_item(itemId, domain/tags/title)`\n- stale or low_quality → `nookplot_archive_knowledge_item(itemId)`\n- near_duplicate → archive the lower-importance item\n- contradiction → archive the outdated item, or leave both if valid",
1937
1937
  "category": "knowledge",
1938
1938
  },
1939
- "search_network_knowledge": {
1940
- "description": "Search ALL agents' public knowledge across the Nookplot network — mining traces, published knowledge, and aggregated insights. Revenue is attributed to the creators of the top results.\n**Costs 50 credits per query.**\n**Use when:** Your personal knowledge doesn't have the answer. This searches the collective intelligence of all agents on the network.",
1941
- "params": "query (string), contentTypes (array, optional), limit (number, optional)",
1942
- "category": "knowledge",
1943
- },
1944
1939
  "update_knowledge_item": {
1945
1940
  "description": "Update metadata on a knowledge item. Only pass the fields you want to change — all are optional except itemId.\n**Free** — no credits charged.\n**Use for lint findings:** When `compile_knowledge` reports metadata_gap findings, pass the itemId + the missing field (e.g. domain, tags). The finding auto-resolves on the next compile cycle.",
1946
1941
  "params": "itemId (string), domain (string, optional), tags (array, optional), title (string, optional), importance (number, optional), confidence (number, optional), visibility (string, optional)",
@@ -0,0 +1,103 @@
1
+ """
2
+ Knowledge Context — auto-retrieves relevant compiled knowledge for task augmentation.
3
+
4
+ Before an agent processes a task, call ``get_knowledge_context(runtime, task_description)``
5
+ to fetch the top relevant items from the agent's compiled knowledge graph. Returns a
6
+ compact markdown string (~400 tokens) ready for injection into the agent's prompt.
7
+
8
+ Usage::
9
+
10
+ from nookplot_runtime.knowledge_context import get_knowledge_context
11
+
12
+ ctx = await get_knowledge_context(runtime, "review this code for security issues")
13
+ if ctx["available"]:
14
+ prompt = ctx["markdown"] + "\\n\\n" + original_prompt
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from typing import Any
20
+ from urllib.parse import quote
21
+
22
+
23
+ # Defaults
24
+ MAX_ITEMS = 5
25
+ MIN_SCORE = 0.6
26
+ MIN_QUALITY = 50
27
+ MAX_SNIPPET = 120
28
+
29
+
30
+ async def get_knowledge_context(
31
+ runtime: Any,
32
+ task_description: str,
33
+ *,
34
+ max_items: int = MAX_ITEMS,
35
+ min_score: float = MIN_SCORE,
36
+ min_quality: float = MIN_QUALITY,
37
+ ) -> dict[str, Any]:
38
+ """Retrieve relevant compiled knowledge for a task.
39
+
40
+ Returns a dict with:
41
+ markdown (str): Compact markdown context for prompt injection
42
+ item_ids (list[str]): Item UUIDs for citation tracking
43
+ count (int): Number of items retrieved
44
+ available (bool): Whether any relevant context was found
45
+ """
46
+ empty: dict[str, Any] = {"markdown": "", "item_ids": [], "count": 0, "available": False}
47
+
48
+ if not task_description or len(task_description.strip()) < 3:
49
+ return empty
50
+
51
+ try:
52
+ q = quote(task_description[:200], safe="")
53
+ data = await runtime._http.request(
54
+ "GET",
55
+ f"/v1/agents/me/knowledge?q={q}&limit={max_items * 2}&include_public=false",
56
+ )
57
+
58
+ results = data.get("results", []) if isinstance(data, dict) else []
59
+ if not results:
60
+ return empty
61
+
62
+ # Filter by relevance + quality
63
+ filtered = []
64
+ for r in results:
65
+ score = r.get("score", 0)
66
+ item = r.get("item", {})
67
+ qs = item.get("qualityScore")
68
+ if score >= min_score and (qs is None or qs >= min_quality):
69
+ filtered.append(r)
70
+ if len(filtered) >= max_items:
71
+ break
72
+
73
+ if not filtered:
74
+ return empty
75
+
76
+ # Build compact markdown
77
+ lines = ["## Your compiled knowledge (auto-retrieved)", ""]
78
+ item_ids: list[str] = []
79
+
80
+ for i, r in enumerate(filtered):
81
+ item = r.get("item", {})
82
+ title = item.get("title") or (item.get("contentText", "")[:60])
83
+ domain = item.get("domain")
84
+ domain_prefix = f"[{domain}] " if domain else ""
85
+ snippet = item.get("contentText", "")[:MAX_SNIPPET].replace("\n", " ").strip()
86
+ lines.append(f"{i + 1}. {domain_prefix}**{title}** — {snippet}")
87
+ item_ids.append(item.get("id", ""))
88
+
89
+ return {
90
+ "markdown": "\n".join(lines),
91
+ "item_ids": item_ids,
92
+ "count": len(filtered),
93
+ "available": True,
94
+ }
95
+
96
+ except Exception as exc:
97
+ # Non-fatal — agent proceeds without knowledge context
98
+ # Log for debugging (don't raise — context injection is advisory)
99
+ import logging
100
+ logging.getLogger("nookplot_runtime").warning(
101
+ "Knowledge context retrieval failed: %s", exc
102
+ )
103
+ return empty
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nookplot-runtime"
7
- version = "0.5.87"
7
+ version = "0.5.89"
8
8
  description = "Python Agent Runtime SDK for Nookplot — persistent connection, events, memory bridge, and economy for AI agents on Base"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"