cogno-cortex 0.1.0__py3-none-any.whl
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.
- cogno_cortex/__init__.py +46 -0
- cogno_cortex/base.py +98 -0
- cogno_cortex/bus.py +95 -0
- cogno_cortex/dispatcher.py +90 -0
- cogno_cortex/loader.py +128 -0
- cogno_cortex/py.typed +0 -0
- cogno_cortex/registry.py +83 -0
- cogno_cortex/types.py +115 -0
- cogno_cortex-0.1.0.dist-info/METADATA +158 -0
- cogno_cortex-0.1.0.dist-info/RECORD +13 -0
- cogno_cortex-0.1.0.dist-info/WHEEL +5 -0
- cogno_cortex-0.1.0.dist-info/licenses/LICENSE +201 -0
- cogno_cortex-0.1.0.dist-info/top_level.txt +1 -0
cogno_cortex/__init__.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""cogno-cortex — the in-process skills framework for the Cogno stack.
|
|
2
|
+
|
|
3
|
+
Skills are authored as ``BaseTool`` subclasses + ``SkillManifest`` metadata,
|
|
4
|
+
ranked against NER tags by ``SkillRegistry``, executed by ``SkillBus`` (via a
|
|
5
|
+
``SkillProvider`` — ``LocalProvider`` ships), and discovered from disk by the
|
|
6
|
+
loader. ``CortexDispatcher`` bridges them to cogno-anima's ``ToolDispatcher`` so the
|
|
7
|
+
EGO / cogno-soma see skills as ordinary tools — merge with MCP/native sources via
|
|
8
|
+
``cogno_anima.tools.CompositeDispatcher``.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from cogno_cortex.base import BasePromptTool, BaseTool, ToolContext
|
|
12
|
+
from cogno_cortex.bus import (
|
|
13
|
+
LocalProvider,
|
|
14
|
+
SkillBus,
|
|
15
|
+
SkillNotFoundError,
|
|
16
|
+
SkillProvider,
|
|
17
|
+
)
|
|
18
|
+
from cogno_cortex.dispatcher import CortexDispatcher
|
|
19
|
+
from cogno_cortex.loader import (
|
|
20
|
+
discover,
|
|
21
|
+
load_skill_dir,
|
|
22
|
+
parse_frontmatter,
|
|
23
|
+
register_all,
|
|
24
|
+
)
|
|
25
|
+
from cogno_cortex.registry import SkillRegistry
|
|
26
|
+
from cogno_cortex.types import SkillManifest, SkillResult
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"BaseTool",
|
|
30
|
+
"BasePromptTool",
|
|
31
|
+
"ToolContext",
|
|
32
|
+
"SkillManifest",
|
|
33
|
+
"SkillResult",
|
|
34
|
+
"SkillRegistry",
|
|
35
|
+
"SkillBus",
|
|
36
|
+
"SkillProvider",
|
|
37
|
+
"LocalProvider",
|
|
38
|
+
"SkillNotFoundError",
|
|
39
|
+
"CortexDispatcher",
|
|
40
|
+
"discover",
|
|
41
|
+
"load_skill_dir",
|
|
42
|
+
"register_all",
|
|
43
|
+
"parse_frontmatter",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
__version__ = "0.1.0"
|
cogno_cortex/base.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Skill authoring contracts: ``BaseTool`` / ``BasePromptTool`` / ``ToolContext``.
|
|
2
|
+
|
|
3
|
+
A skill is a ``BaseTool`` subclass: its Pydantic fields ARE the tool's arguments,
|
|
4
|
+
and ``run(context)`` executes it, returning a :class:`SkillResult`. ``ToolContext``
|
|
5
|
+
carries the injected LLM backend + free-form metadata (the host passes domains,
|
|
6
|
+
constraints, the user query, etc.) — note it carries NO pipeline/DB handle: a skill
|
|
7
|
+
is infra-agnostic, exactly like the rest of the stack.
|
|
8
|
+
|
|
9
|
+
Ported from the parent ``cogno.skills.base``; the ``PipelineContext`` coupling of
|
|
10
|
+
the parent's ``ToolContext`` is replaced by a plain ``metadata`` dict.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from abc import ABC, abstractmethod
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from pydantic import BaseModel, ConfigDict
|
|
19
|
+
|
|
20
|
+
from cogno_cortex.types import SkillResult
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ToolContext(BaseModel):
|
|
24
|
+
"""Execution context passed to a skill's ``run()``.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
backend: an injected ``cogno_synapse.LLMBackend`` (typed ``Any`` to avoid a
|
|
28
|
+
hard import + circulars); ``None`` for skills that need no LLM.
|
|
29
|
+
trace_id: optional correlation id for observability.
|
|
30
|
+
metadata: extra context from the host (domains, constraints, user query, ...).
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
backend: Any = None
|
|
34
|
+
trace_id: str = ""
|
|
35
|
+
metadata: dict[str, Any] = {}
|
|
36
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class BaseTool(BaseModel, ABC):
|
|
40
|
+
"""Abstract base for all skills. Subclasses declare arguments as Pydantic fields.
|
|
41
|
+
|
|
42
|
+
Example::
|
|
43
|
+
|
|
44
|
+
class MathTool(BaseTool):
|
|
45
|
+
a: float
|
|
46
|
+
op: str
|
|
47
|
+
b: float
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def name(self) -> str: return "math"
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def description(self) -> str: return "Basic arithmetic."
|
|
54
|
+
|
|
55
|
+
async def run(self, context: ToolContext) -> SkillResult:
|
|
56
|
+
...
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
@abstractmethod
|
|
63
|
+
def name(self) -> str:
|
|
64
|
+
"""Unique skill name (must match the ``SkillManifest.name``)."""
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def description(self) -> str:
|
|
69
|
+
"""Human-readable description of what this skill does."""
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
async def run(self, context: ToolContext) -> SkillResult:
|
|
73
|
+
"""Execute the skill and return a :class:`SkillResult`."""
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def args_schema(cls) -> dict[str, Any]:
|
|
77
|
+
"""JSON-Schema for this skill's arguments (its Pydantic fields)."""
|
|
78
|
+
return cls.model_json_schema()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class BasePromptTool(BaseTool):
|
|
82
|
+
"""Convenience base for LLM-driven skills: ``run`` formats a prompt + calls the backend."""
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
@abstractmethod
|
|
86
|
+
def prompt_template(self) -> str:
|
|
87
|
+
"""A ``str.format`` template with ``{field_name}`` placeholders."""
|
|
88
|
+
|
|
89
|
+
async def run(self, context: ToolContext) -> SkillResult:
|
|
90
|
+
formatted = self.prompt_template.format(**self.model_dump())
|
|
91
|
+
response = await context.backend.generate("You are a specialized tool assistant.", formatted)
|
|
92
|
+
text = response[0] if isinstance(response, tuple) else response
|
|
93
|
+
usage: dict[str, int] = {}
|
|
94
|
+
if isinstance(response, tuple) and len(response) >= 3:
|
|
95
|
+
usage = {"tokens_in": response[1], "tokens_out": response[2]}
|
|
96
|
+
return SkillResult(
|
|
97
|
+
skill_name=self.name, payload=text, status="success",
|
|
98
|
+
evidence=[f"prompt tool '{self.name}' executed"], usage=usage)
|
cogno_cortex/bus.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""``SkillBus`` — provider-based skill dispatch.
|
|
2
|
+
|
|
3
|
+
The bus maps a skill name → its execution provider. ``LocalProvider`` runs an
|
|
4
|
+
in-process ``BaseTool`` (the only provider cortex ships); the ``SkillProvider``
|
|
5
|
+
Protocol is the seam a host plugs shell/http/remote providers into (those carry
|
|
6
|
+
subprocess/network + security decisions that are host concerns).
|
|
7
|
+
|
|
8
|
+
Ported from the parent ``cogno.skills.bus`` — the os/JSONL debug logging is dropped
|
|
9
|
+
in favour of the house-rule structured logger (lazy ``key=value``, no handlers).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
from typing import Any, Optional, Protocol, runtime_checkable
|
|
16
|
+
|
|
17
|
+
from cogno_cortex.base import ToolContext
|
|
18
|
+
from cogno_cortex.types import SkillManifest, SkillResult
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@runtime_checkable
|
|
24
|
+
class SkillProvider(Protocol):
|
|
25
|
+
"""Execution backend for a class of skills."""
|
|
26
|
+
|
|
27
|
+
def supports(self, manifest: SkillManifest) -> bool:
|
|
28
|
+
"""Return True if this provider can execute the given manifest."""
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
async def invoke(
|
|
32
|
+
self, manifest: SkillManifest, context: ToolContext,
|
|
33
|
+
tool_args: Optional[dict[str, Any]] = None,
|
|
34
|
+
) -> SkillResult:
|
|
35
|
+
"""Execute the skill and return a :class:`SkillResult`."""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class LocalProvider:
|
|
40
|
+
"""Runs skills that carry a ``tool_class`` (a ``BaseTool`` subclass), in-process."""
|
|
41
|
+
|
|
42
|
+
def supports(self, manifest: SkillManifest) -> bool:
|
|
43
|
+
return manifest.tool_class is not None
|
|
44
|
+
|
|
45
|
+
async def invoke(
|
|
46
|
+
self, manifest: SkillManifest, context: ToolContext,
|
|
47
|
+
tool_args: Optional[dict[str, Any]] = None,
|
|
48
|
+
) -> SkillResult:
|
|
49
|
+
if manifest.tool_class is None:
|
|
50
|
+
raise RuntimeError(f"manifest '{manifest.name}' has no tool_class")
|
|
51
|
+
tool = manifest.tool_class(**(tool_args or {}))
|
|
52
|
+
return await tool.run(context)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class SkillNotFoundError(KeyError):
|
|
56
|
+
"""Raised by the bus when a skill name has no registered manifest."""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class SkillBus:
|
|
60
|
+
"""Dispatches skill invocations to the first registered provider that supports them."""
|
|
61
|
+
|
|
62
|
+
def __init__(self) -> None:
|
|
63
|
+
self.providers: list[SkillProvider] = []
|
|
64
|
+
self._manifests: dict[str, SkillManifest] = {}
|
|
65
|
+
|
|
66
|
+
def register_provider(self, provider: SkillProvider) -> None:
|
|
67
|
+
self.providers.append(provider)
|
|
68
|
+
|
|
69
|
+
def register_manifest(self, manifest: SkillManifest) -> None:
|
|
70
|
+
self._manifests[manifest.name] = manifest
|
|
71
|
+
|
|
72
|
+
def get_manifest(self, skill_name: str) -> Optional[SkillManifest]:
|
|
73
|
+
return self._manifests.get(skill_name)
|
|
74
|
+
|
|
75
|
+
async def invoke(
|
|
76
|
+
self, skill_name: str, context: ToolContext,
|
|
77
|
+
tool_args: Optional[dict[str, Any]] = None,
|
|
78
|
+
) -> SkillResult:
|
|
79
|
+
"""Execute a skill by name.
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
SkillNotFoundError: the name has no registered manifest.
|
|
83
|
+
RuntimeError: no provider supports the manifest.
|
|
84
|
+
"""
|
|
85
|
+
manifest = self._manifests.get(skill_name)
|
|
86
|
+
if manifest is None:
|
|
87
|
+
raise SkillNotFoundError(skill_name)
|
|
88
|
+
for provider in self.providers:
|
|
89
|
+
if provider.supports(manifest):
|
|
90
|
+
result = await provider.invoke(manifest, context, tool_args)
|
|
91
|
+
result.skill_name = skill_name # dispatched name wins over a generic tool name
|
|
92
|
+
logger.debug("event=skill_invoked name=%s provider=%s status=%s",
|
|
93
|
+
skill_name, manifest.provider_type, result.status)
|
|
94
|
+
return result
|
|
95
|
+
raise RuntimeError(f"no provider supports skill '{skill_name}'")
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""``CortexDispatcher`` — the bridge from skills to cogno-anima's tool contract.
|
|
2
|
+
|
|
3
|
+
This is the keystone: it implements cogno-anima's ``ToolDispatcher`` (and
|
|
4
|
+
``ToolPolicyDispatcher``), so the EGO / cogno-soma see skills as ordinary tools and
|
|
5
|
+
never know what a "skill" is. ``tools_schema()`` renders the selected manifests as
|
|
6
|
+
OpenAI tool defs; ``execute()`` runs the skill via the bus and maps ``SkillResult``
|
|
7
|
+
→ ``ToolResult``; the policy methods read the manifest's ``mutating`` / ``destructive``
|
|
8
|
+
flags so the EGO's read-only mask and confirmation gate work for skills too.
|
|
9
|
+
|
|
10
|
+
The host ranks skills first (``SkillRegistry.rank`` against the NER tags) and passes
|
|
11
|
+
the chosen ``names`` — or omits them to expose all registered skills. A skill is
|
|
12
|
+
NOT a tool: it is a richer thing (manifest + provider + impl) that *resolves to* one
|
|
13
|
+
tool here. The ``ToolDispatcher`` contract is the unifier; merge cortex with an MCP
|
|
14
|
+
or native dispatcher via ``cogno_anima.tools.CompositeDispatcher``.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import Any, Optional, Sequence
|
|
20
|
+
|
|
21
|
+
from cogno_anima.types import ToolResult
|
|
22
|
+
|
|
23
|
+
from cogno_cortex.base import ToolContext
|
|
24
|
+
from cogno_cortex.bus import SkillBus, SkillNotFoundError
|
|
25
|
+
from cogno_cortex.registry import SkillRegistry
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CortexDispatcher:
|
|
29
|
+
"""A cogno-anima ``ToolDispatcher`` (+ ``ToolPolicyDispatcher``) backed by skills."""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
registry: SkillRegistry,
|
|
34
|
+
bus: SkillBus,
|
|
35
|
+
*,
|
|
36
|
+
names: Optional[Sequence[str]] = None,
|
|
37
|
+
backend: Any = None,
|
|
38
|
+
metadata: Optional[dict] = None,
|
|
39
|
+
trace_id: str = "",
|
|
40
|
+
) -> None:
|
|
41
|
+
"""
|
|
42
|
+
Args:
|
|
43
|
+
registry: source of manifests (for schemas + policy flags).
|
|
44
|
+
bus: executes the skills (must have a provider + the manifests registered).
|
|
45
|
+
names: the skill names to expose this turn (e.g. ``registry.rank(tags)``);
|
|
46
|
+
``None`` → expose every registered skill.
|
|
47
|
+
backend: the ``LLMBackend`` injected into each skill's ``ToolContext``.
|
|
48
|
+
metadata: extra context handed to every skill (domains, user query, ...).
|
|
49
|
+
trace_id: correlation id stamped on the ``ToolContext``.
|
|
50
|
+
"""
|
|
51
|
+
self._registry = registry
|
|
52
|
+
self._bus = bus
|
|
53
|
+
self._names = list(names) if names is not None else registry.skill_names()
|
|
54
|
+
self._backend = backend
|
|
55
|
+
self._metadata = metadata or {}
|
|
56
|
+
self._trace_id = trace_id
|
|
57
|
+
|
|
58
|
+
def _manifest(self, name: str):
|
|
59
|
+
return self._registry.get(name)
|
|
60
|
+
|
|
61
|
+
def tools_schema(self) -> list[dict]:
|
|
62
|
+
schemas = []
|
|
63
|
+
for name in self._names:
|
|
64
|
+
m = self._manifest(name)
|
|
65
|
+
if m is not None:
|
|
66
|
+
schemas.append(m.to_tool_schema())
|
|
67
|
+
return schemas
|
|
68
|
+
|
|
69
|
+
async def execute(self, name: str, arguments: dict) -> ToolResult:
|
|
70
|
+
context = ToolContext(backend=self._backend, trace_id=self._trace_id,
|
|
71
|
+
metadata=dict(self._metadata))
|
|
72
|
+
try:
|
|
73
|
+
result = await self._bus.invoke(name, context, tool_args=arguments)
|
|
74
|
+
except SkillNotFoundError:
|
|
75
|
+
# hallucinated / unknown tool name → recoverable, EGO self-corrects
|
|
76
|
+
return ToolResult(output="", ok=False, error=f"unknown tool: {name}")
|
|
77
|
+
manifest = self._manifest(name)
|
|
78
|
+
side_effect = bool(manifest.mutating) if manifest else False
|
|
79
|
+
if result.ok:
|
|
80
|
+
return ToolResult(output=str(result.payload), ok=True, side_effect=side_effect)
|
|
81
|
+
return ToolResult(output="", ok=False, error=str(result.payload), side_effect=side_effect)
|
|
82
|
+
|
|
83
|
+
# ── ToolPolicyDispatcher ──────────────────────────────────────────────
|
|
84
|
+
def is_mutating(self, name: str) -> bool:
|
|
85
|
+
m = self._manifest(name)
|
|
86
|
+
return bool(m.mutating) if m else True # unknown → conservative (masked read-only)
|
|
87
|
+
|
|
88
|
+
def requires_confirmation(self, name: str) -> bool:
|
|
89
|
+
m = self._manifest(name)
|
|
90
|
+
return bool(m.destructive) if m else False
|
cogno_cortex/loader.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""``SkillLoader`` — discover on-disk skills (``SKILL.md`` + a ``BaseTool``).
|
|
2
|
+
|
|
3
|
+
A skill directory contains a ``SKILL.md`` (YAML-ish frontmatter: name/description/
|
|
4
|
+
tags/... + operational instructions in the body) and one or more ``.py`` files with
|
|
5
|
+
a ``BaseTool`` subclass. ``discover`` scans a root for such directories and returns
|
|
6
|
+
``SkillManifest``s (with ``tool_class`` wired to the found ``BaseTool`` and
|
|
7
|
+
``skill_instructions`` set to the SKILL.md body). ``register_all`` loads them into a
|
|
8
|
+
registry + bus. The XDG/builtins hardcoded paths of the parent are dropped — the
|
|
9
|
+
host passes the directories it wants.
|
|
10
|
+
|
|
11
|
+
Frontmatter parsing mirrors cogno-persona's loader (simple ``key: value`` + ``- list``).
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import importlib.util
|
|
17
|
+
import inspect
|
|
18
|
+
import logging
|
|
19
|
+
import re
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Optional, Type
|
|
22
|
+
|
|
23
|
+
from cogno_cortex.base import BaseTool
|
|
24
|
+
from cogno_cortex.bus import SkillBus
|
|
25
|
+
from cogno_cortex.registry import SkillRegistry
|
|
26
|
+
from cogno_cortex.types import SkillManifest
|
|
27
|
+
|
|
28
|
+
logger = logging.getLogger(__name__)
|
|
29
|
+
|
|
30
|
+
_FRONTMATTER_RE = re.compile(r"\A---\s*\n(.*?)\n---\s*\n?(.*)\Z", re.DOTALL)
|
|
31
|
+
_BOOL_TRUE = {"true", "yes", "1"}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def parse_frontmatter(text: str) -> tuple[dict, str]:
|
|
35
|
+
"""Split ``---``-delimited frontmatter from the body. Returns ``(meta, body)``."""
|
|
36
|
+
m = _FRONTMATTER_RE.match(text)
|
|
37
|
+
if not m:
|
|
38
|
+
return {}, text
|
|
39
|
+
raw, body = m.group(1), m.group(2)
|
|
40
|
+
meta: dict = {}
|
|
41
|
+
key: Optional[str] = None
|
|
42
|
+
for line in raw.splitlines():
|
|
43
|
+
if not line.strip():
|
|
44
|
+
continue
|
|
45
|
+
list_item = re.match(r"\s*-\s+(.*)", line)
|
|
46
|
+
if list_item and key is not None and isinstance(meta.get(key), list):
|
|
47
|
+
meta[key].append(list_item.group(1).strip().strip("'\""))
|
|
48
|
+
continue
|
|
49
|
+
kv = re.match(r"([A-Za-z0-9_]+)\s*:\s*(.*)", line)
|
|
50
|
+
if not kv:
|
|
51
|
+
continue
|
|
52
|
+
key, val = kv.group(1), kv.group(2).strip()
|
|
53
|
+
if val == "":
|
|
54
|
+
meta[key] = [] # a list follows on the next lines
|
|
55
|
+
else:
|
|
56
|
+
meta[key] = val.strip("'\"")
|
|
57
|
+
return meta, body.strip()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _find_tool_class(skill_dir: Path) -> Optional[Type[BaseTool]]:
|
|
61
|
+
"""Import the .py files in ``skill_dir`` and return the first ``BaseTool`` subclass."""
|
|
62
|
+
for py in sorted(skill_dir.glob("*.py")):
|
|
63
|
+
if py.name == "__init__.py":
|
|
64
|
+
continue
|
|
65
|
+
spec = importlib.util.spec_from_file_location(f"_cortex_skill_{py.stem}", py)
|
|
66
|
+
if spec is None or spec.loader is None:
|
|
67
|
+
continue
|
|
68
|
+
module = importlib.util.module_from_spec(spec)
|
|
69
|
+
try:
|
|
70
|
+
spec.loader.exec_module(module)
|
|
71
|
+
except Exception as exc: # noqa: BLE001 — a broken skill file must not crash discovery
|
|
72
|
+
logger.warning("event=skill_import_failed file=%s error=%s", py.name, exc)
|
|
73
|
+
continue
|
|
74
|
+
for _, obj in inspect.getmembers(module, inspect.isclass):
|
|
75
|
+
if issubclass(obj, BaseTool) and obj.__module__ == module.__name__:
|
|
76
|
+
return obj
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def load_skill_dir(skill_dir: Path) -> Optional[SkillManifest]:
|
|
81
|
+
"""Build a ``SkillManifest`` from one skill directory (needs a ``SKILL.md``)."""
|
|
82
|
+
md = skill_dir / "SKILL.md"
|
|
83
|
+
if not md.exists():
|
|
84
|
+
return None
|
|
85
|
+
meta, body = parse_frontmatter(md.read_text(encoding="utf-8"))
|
|
86
|
+
name = meta.get("name") or skill_dir.name
|
|
87
|
+
tool_class = _find_tool_class(skill_dir)
|
|
88
|
+
raw_tags = meta.get("tags", [])
|
|
89
|
+
if isinstance(raw_tags, list):
|
|
90
|
+
tags: list[str] = [str(t) for t in raw_tags]
|
|
91
|
+
else:
|
|
92
|
+
tags = [t.strip() for t in str(raw_tags).split(",") if t.strip()]
|
|
93
|
+
return SkillManifest(
|
|
94
|
+
name=name,
|
|
95
|
+
description=meta.get("description", ""),
|
|
96
|
+
tags=tags,
|
|
97
|
+
version=meta.get("version", "0.1.0"),
|
|
98
|
+
provider_type=meta.get("provider", "local"),
|
|
99
|
+
priority=int(meta.get("priority", 5)),
|
|
100
|
+
mutating=str(meta.get("mutating", "false")).lower() in _BOOL_TRUE,
|
|
101
|
+
destructive=str(meta.get("destructive", "false")).lower() in _BOOL_TRUE,
|
|
102
|
+
tool_class=tool_class,
|
|
103
|
+
skill_instructions=body,
|
|
104
|
+
metadata={"source_dir": str(skill_dir)},
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def discover(root: Path | str) -> list[SkillManifest]:
|
|
109
|
+
"""Discover all skills under ``root`` (each immediate subdir with a ``SKILL.md``)."""
|
|
110
|
+
root = Path(root)
|
|
111
|
+
manifests: list[SkillManifest] = []
|
|
112
|
+
if not root.is_dir():
|
|
113
|
+
return manifests
|
|
114
|
+
for child in sorted(root.iterdir()):
|
|
115
|
+
if child.is_dir():
|
|
116
|
+
man = load_skill_dir(child)
|
|
117
|
+
if man is not None:
|
|
118
|
+
manifests.append(man)
|
|
119
|
+
return manifests
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def register_all(
|
|
123
|
+
manifests: list[SkillManifest], registry: SkillRegistry, bus: SkillBus,
|
|
124
|
+
) -> None:
|
|
125
|
+
"""Register every manifest in both the registry (ranking) and the bus (dispatch)."""
|
|
126
|
+
for man in manifests:
|
|
127
|
+
registry.register(man)
|
|
128
|
+
bus.register_manifest(man)
|
cogno_cortex/py.typed
ADDED
|
File without changes
|
cogno_cortex/registry.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""``SkillRegistry`` — tag-based skill matching and ranking (pure, no I/O).
|
|
2
|
+
|
|
3
|
+
Ranks registered manifests against NER-extracted tags (domains + mandatory_tags +
|
|
4
|
+
intent hints) so the host can pick the most relevant skills to expose to the EGO.
|
|
5
|
+
Ported from the parent ``cogno.skills.registry``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Optional
|
|
11
|
+
|
|
12
|
+
from cogno_cortex.types import SkillManifest
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SkillRegistry:
|
|
16
|
+
"""Holds ``SkillManifest``s and ranks them by tag overlap.
|
|
17
|
+
|
|
18
|
+
Ranking (descending): direct name match (+100) → tag overlap (+10 each) →
|
|
19
|
+
tie-break by (priority, performance_rating).
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
self._manifests: list[SkillManifest] = []
|
|
24
|
+
|
|
25
|
+
def register(self, manifest: SkillManifest) -> None:
|
|
26
|
+
# replace an existing manifest of the same name (idempotent re-register)
|
|
27
|
+
self._manifests = [m for m in self._manifests if m.name != manifest.name]
|
|
28
|
+
self._manifests.append(manifest)
|
|
29
|
+
|
|
30
|
+
def get(self, name: str) -> Optional[SkillManifest]:
|
|
31
|
+
for m in self._manifests:
|
|
32
|
+
if m.name == name:
|
|
33
|
+
return m
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def manifests(self) -> list[SkillManifest]:
|
|
38
|
+
return list(self._manifests)
|
|
39
|
+
|
|
40
|
+
def skill_names(self) -> list[str]:
|
|
41
|
+
return [m.name for m in self._manifests]
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def _normalize_tags(tags: list[str]) -> set[str]:
|
|
45
|
+
"""Lowercase + strip a ``NER.`` prefix (NER emits ``NER.MATH`` → ``math``)."""
|
|
46
|
+
out: set[str] = set()
|
|
47
|
+
for tag in tags:
|
|
48
|
+
low = tag.lower()
|
|
49
|
+
out.add(low)
|
|
50
|
+
if low.startswith("ner."):
|
|
51
|
+
out.add(low[4:])
|
|
52
|
+
return out
|
|
53
|
+
|
|
54
|
+
def rank(self, tags: list[str], *, max_results: int = 3) -> list[str]:
|
|
55
|
+
"""Return up to ``max_results`` skill names ordered by relevance to ``tags``."""
|
|
56
|
+
tags_set = self._normalize_tags(tags)
|
|
57
|
+
scored: list[tuple[tuple[int, int, float], SkillManifest]] = []
|
|
58
|
+
for m in self._manifests:
|
|
59
|
+
score = 0
|
|
60
|
+
if m.name.lower() in tags_set:
|
|
61
|
+
score += 100
|
|
62
|
+
overlap = {t.lower() for t in m.tags} & tags_set
|
|
63
|
+
score += len(overlap) * 10
|
|
64
|
+
if score > 0:
|
|
65
|
+
scored.append(((score, m.priority, m.performance_rating), m))
|
|
66
|
+
scored.sort(key=lambda x: x[0], reverse=True)
|
|
67
|
+
return [m.name for _, m in scored[:max_results]]
|
|
68
|
+
|
|
69
|
+
def apply_feedback(self, skill_name: str, feedback: str) -> None:
|
|
70
|
+
"""Nudge a skill's ``performance_rating`` from execution feedback.
|
|
71
|
+
|
|
72
|
+
``good`` → +0.1, ``bad`` → −0.1, ``dangerous`` → −0.3 (clamped to [0,1]).
|
|
73
|
+
"""
|
|
74
|
+
m = self.get(skill_name)
|
|
75
|
+
if m is None:
|
|
76
|
+
return
|
|
77
|
+
fb = feedback.lower()
|
|
78
|
+
if fb == "good":
|
|
79
|
+
m.performance_rating = min(1.0, m.performance_rating + 0.1)
|
|
80
|
+
elif fb == "bad":
|
|
81
|
+
m.performance_rating = max(0.0, m.performance_rating - 0.1)
|
|
82
|
+
elif fb == "dangerous":
|
|
83
|
+
m.performance_rating = max(0.0, m.performance_rating - 0.3)
|
cogno_cortex/types.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Data contracts for the skill framework.
|
|
2
|
+
|
|
3
|
+
``SkillManifest`` — declarative metadata for registry/ranking + the OpenAI tool
|
|
4
|
+
schema the EGO sees. ``SkillResult`` — the structured output a skill returns.
|
|
5
|
+
|
|
6
|
+
Ported from the parent ``cogno.skills.types`` with the infra-leaning fields
|
|
7
|
+
trimmed (XDG paths, sub-doc dirs) and two policy flags added (``mutating`` /
|
|
8
|
+
``destructive``) so a :class:`~cogno_cortex.dispatcher.CortexDispatcher` can satisfy
|
|
9
|
+
cogno-anima's ``ToolPolicyDispatcher`` and drive the EGO's read-only / confirmation
|
|
10
|
+
gates.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from typing import Any, Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class SkillManifest:
|
|
21
|
+
"""Declarative metadata for a registered skill.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
name: Unique skill identifier (e.g. "math", "search").
|
|
25
|
+
description: One-line capability summary (shown to the model).
|
|
26
|
+
tags: Discovery tags — matched against NER domains/mandatory_tags.
|
|
27
|
+
parameters: JSON-Schema for the tool's arguments (OpenAI format). Empty
|
|
28
|
+
dict → a minimal ``{query: string}`` schema.
|
|
29
|
+
version: Semver string.
|
|
30
|
+
provider_type: Execution backend label ("local", "shell", "http", ...).
|
|
31
|
+
priority: Tie-breaker for equally-scored skills (higher = preferred).
|
|
32
|
+
performance_rating: Adaptive quality score (0..1), nudged by ``apply_feedback``.
|
|
33
|
+
tool_class: The ``BaseTool`` subclass that implements this skill (for the
|
|
34
|
+
in-process ``LocalProvider``); ``None`` for provider-only skills.
|
|
35
|
+
skill_instructions: Operational instructions (from SKILL.md) the model may read.
|
|
36
|
+
mutating: True if the skill writes / causes a side effect (drives the
|
|
37
|
+
EGO read-only mask).
|
|
38
|
+
destructive: True if the skill is dangerous and must be confirmed first
|
|
39
|
+
(drives the EGO confirmation gate).
|
|
40
|
+
pricing_model: "free" | "per_call" (metadata; metering is cogno-meter's job).
|
|
41
|
+
unit_cost: Cost per invocation (metadata only).
|
|
42
|
+
timeout_seconds: Advisory max execution time.
|
|
43
|
+
metadata: Free-form extra (model name, source dir, etc.).
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
name: str
|
|
47
|
+
description: str = ""
|
|
48
|
+
tags: list[str] = field(default_factory=list)
|
|
49
|
+
parameters: dict[str, Any] = field(default_factory=dict)
|
|
50
|
+
version: str = "0.1.0"
|
|
51
|
+
provider_type: str = "local"
|
|
52
|
+
priority: int = 5
|
|
53
|
+
performance_rating: float = 0.5
|
|
54
|
+
tool_class: Optional[Any] = None
|
|
55
|
+
skill_instructions: str = ""
|
|
56
|
+
mutating: bool = False
|
|
57
|
+
destructive: bool = False
|
|
58
|
+
pricing_model: str = "free"
|
|
59
|
+
unit_cost: float = 0.0
|
|
60
|
+
timeout_seconds: float = 30.0
|
|
61
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
62
|
+
|
|
63
|
+
def to_tool_schema(self) -> dict[str, Any]:
|
|
64
|
+
"""Render this manifest as an OpenAI function-calling tool definition.
|
|
65
|
+
|
|
66
|
+
With no ``parameters`` declared, falls back to a minimal ``{query: string}``
|
|
67
|
+
schema (the skill reads the raw user query).
|
|
68
|
+
"""
|
|
69
|
+
params = self.parameters or {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"query": {"type": "string",
|
|
73
|
+
"description": "The user's query or input for this tool"}
|
|
74
|
+
},
|
|
75
|
+
"required": ["query"],
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
"type": "function",
|
|
79
|
+
"function": {
|
|
80
|
+
"name": self.name,
|
|
81
|
+
"description": self.description,
|
|
82
|
+
"parameters": params,
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass
|
|
88
|
+
class SkillResult:
|
|
89
|
+
"""Structured output from a skill execution.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
skill_name: Which skill produced this result.
|
|
93
|
+
payload: The actual output (text / JSON-serialisable value).
|
|
94
|
+
status: "success" | "error" | "blocked".
|
|
95
|
+
evidence: Strings explaining what was done.
|
|
96
|
+
risks: Risk strings (empty if safe).
|
|
97
|
+
confidence: 0..1 confidence in result quality.
|
|
98
|
+
provider_type: Execution backend used.
|
|
99
|
+
usage: Token usage if an LLM was involved ({"tokens_in", "tokens_out"}).
|
|
100
|
+
metadata: Extra context (model name, etc.).
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
skill_name: str
|
|
104
|
+
payload: Any
|
|
105
|
+
status: str = "success"
|
|
106
|
+
evidence: list[str] = field(default_factory=list)
|
|
107
|
+
risks: list[str] = field(default_factory=list)
|
|
108
|
+
confidence: float = 1.0
|
|
109
|
+
provider_type: str = "local"
|
|
110
|
+
usage: dict[str, int] = field(default_factory=dict)
|
|
111
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def ok(self) -> bool:
|
|
115
|
+
return self.status == "success"
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cogno-cortex
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The in-process skills framework for the Cogno stack — author skills as BaseTool + manifest, rank them against NER tags, execute via a provider bus, discover from disk, and bridge to cogno-anima's tool contract via CortexDispatcher. The framework, not the skills; infra-agnostic.
|
|
5
|
+
Author: Vinicius Vale
|
|
6
|
+
Maintainer: Sudoers AI
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/sudoers-ai/cogno-cortex
|
|
9
|
+
Project-URL: Repository, https://github.com/sudoers-ai/cogno-cortex
|
|
10
|
+
Project-URL: Issues, https://github.com/sudoers-ai/cogno-cortex/issues
|
|
11
|
+
Keywords: skills,tools,agents,function-calling,cogno,llm
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: cogno-anima<0.2,>=0.1
|
|
26
|
+
Requires-Dist: cogno-synapse<0.2,>=0.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# cogno-cortex
|
|
36
|
+
|
|
37
|
+
**The in-process skills framework for the Cogno stack.**
|
|
38
|
+
|
|
39
|
+
A *skill* is a richer thing than a tool: a `BaseTool` implementation **+** a
|
|
40
|
+
`SkillManifest` (tags, policy flags, instructions) for discovery and ranking.
|
|
41
|
+
cortex is the layer that authors, discovers, ranks and executes skills — and then
|
|
42
|
+
**bridges them to a plain tool** via `CortexDispatcher`, so the EGO / `cogno-soma`
|
|
43
|
+
see ordinary tools and never know what a "skill" is.
|
|
44
|
+
|
|
45
|
+
cortex ships the **framework, not the skills** (like `cogno-persona` ships the
|
|
46
|
+
store, not the personas). It is infra-agnostic: in-process execution only; shell /
|
|
47
|
+
http / remote providers are a host seam.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
SKILL.md + BaseTool ─▶ SkillRegistry.rank(NER tags) ─▶ CortexDispatcher
|
|
51
|
+
│ (implements
|
|
52
|
+
▼ cogno-anima's
|
|
53
|
+
soma.run_turn(dispatcher=…) → EGO
|
|
54
|
+
ToolDispatcher)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install cogno-cortex # pulls cogno-anima + cogno-synapse + pydantic
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> The sibling cogno libs are not on PyPI yet — install them from git first
|
|
64
|
+
> (`cogno-homeo`, `cogno-synapse`, `cogno-anima`); see `.github/workflows/ci.yml`.
|
|
65
|
+
|
|
66
|
+
## Author a skill
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from cogno_cortex import BaseTool, SkillResult, ToolContext
|
|
70
|
+
|
|
71
|
+
class MathTool(BaseTool):
|
|
72
|
+
a: float
|
|
73
|
+
op: str # the Pydantic fields ARE the tool arguments
|
|
74
|
+
b: float
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def name(self): return "math"
|
|
78
|
+
@property
|
|
79
|
+
def description(self): return "Basic arithmetic."
|
|
80
|
+
|
|
81
|
+
async def run(self, ctx: ToolContext) -> SkillResult:
|
|
82
|
+
val = {"+": self.a + self.b, "*": self.a * self.b}[self.op]
|
|
83
|
+
return SkillResult(skill_name=self.name, payload=val)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Pair it with a `SKILL.md` (frontmatter: `name`, `description`, `tags`, `priority`,
|
|
87
|
+
`mutating`, `destructive` + operational instructions in the body) in a directory,
|
|
88
|
+
and `discover()` loads it.
|
|
89
|
+
|
|
90
|
+
## Wire it to the EGO
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from cogno_cortex import (SkillRegistry, SkillBus, LocalProvider,
|
|
94
|
+
CortexDispatcher, discover, register_all)
|
|
95
|
+
|
|
96
|
+
registry, bus = SkillRegistry(), SkillBus()
|
|
97
|
+
bus.register_provider(LocalProvider())
|
|
98
|
+
register_all(discover("./skills"), registry, bus)
|
|
99
|
+
|
|
100
|
+
chosen = registry.rank(ctx.intent.domains + ctx.intent.mandatory_tags) # NER-driven
|
|
101
|
+
dispatcher = CortexDispatcher(registry, bus, names=chosen, backend=llm_backend)
|
|
102
|
+
|
|
103
|
+
# hand it straight to cogno-soma:
|
|
104
|
+
await pipe.run_turn(ctx, cfg, dispatcher=dispatcher)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`CortexDispatcher` implements cogno-anima's `ToolDispatcher` **and**
|
|
108
|
+
`ToolPolicyDispatcher`: `tools_schema()` renders the chosen manifests; `execute()`
|
|
109
|
+
runs the skill and maps `SkillResult → ToolResult`; `is_mutating` / `requires_confirmation`
|
|
110
|
+
read the manifest flags so the EGO's read-only mask + confirmation gate work for
|
|
111
|
+
skills too.
|
|
112
|
+
|
|
113
|
+
## Skills + MCP + native tools together
|
|
114
|
+
|
|
115
|
+
A persona may draw tools from several sources at once. Each source is a
|
|
116
|
+
`ToolDispatcher`; merge them with `cogno_anima.tools.CompositeDispatcher`:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from cogno_anima.tools import CompositeDispatcher
|
|
120
|
+
dispatcher = CompositeDispatcher([cortex_dispatcher, mcp_dispatcher, native_dispatcher])
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The `ToolDispatcher` contract is the unifier — skill / MCP / native are just
|
|
124
|
+
sources behind it. The persona declares modules **by name**; the host resolves each
|
|
125
|
+
to a source and composes.
|
|
126
|
+
|
|
127
|
+
## What stays at the host
|
|
128
|
+
|
|
129
|
+
The concrete skills (shell/web/browser/...), shell/http/remote **providers**
|
|
130
|
+
(subprocess/network + security), persona selection, metering (`cogno-meter`), RBAC.
|
|
131
|
+
cortex is the framework; the host plugs providers via the `SkillProvider` Protocol.
|
|
132
|
+
|
|
133
|
+
## The Cogno ecosystem
|
|
134
|
+
|
|
135
|
+
`cogno-cortex` is one organ of **[Cogno](https://github.com/sudoers-ai)** — a family of
|
|
136
|
+
small, composable, Apache-2.0 libraries that together form a complete
|
|
137
|
+
conversational-agent platform. Each library owns a single concern and stays
|
|
138
|
+
infra-agnostic; a **host** assembles them into a running agent:
|
|
139
|
+
|
|
140
|
+

|
|
141
|
+
|
|
142
|
+
The open-source libraries are the organs; the **host is the body** that joins
|
|
143
|
+
them. Our reference host — `cogno-host`, with its `cogno-ui` dashboard — is the
|
|
144
|
+
private product layer, but it holds no special powers: everything it does rides
|
|
145
|
+
on the public seams documented in each library's `docs/HOST_INTEGRATION.md`, so
|
|
146
|
+
you can assemble a body of your own.
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install -e ".[dev]"
|
|
152
|
+
pytest tests/unit -q # fast, no network
|
|
153
|
+
pytest tests/integration -q # real EGO over Ollama, auto-skips if absent
|
|
154
|
+
ruff check cogno_cortex tests && mypy cogno_cortex
|
|
155
|
+
python examples/host_min.py # offline demo: discover → rank → bridge → execute
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Apache-2.0.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
cogno_cortex/__init__.py,sha256=8-HrG2Ctk5cl86L0YRA58qDeuICWCGeIXKW6uXAqQRs,1320
|
|
2
|
+
cogno_cortex/base.py,sha256=-FqMz0bwidyzkOgQy9ocajB2aQ31PS2mXI6BHEjM2Lc,3462
|
|
3
|
+
cogno_cortex/bus.py,sha256=4HDNkkn-KUkdNz-PyAdQdII98d6GGUxjQGGE1MtcVZ0,3562
|
|
4
|
+
cogno_cortex/dispatcher.py,sha256=i3WPr-bEgbAI9GAWoNQtSCiTMzTEtOtcggKWDxJ9Pf4,4114
|
|
5
|
+
cogno_cortex/loader.py,sha256=0Jfty2kMFdKd6kjj7RN3N1tFINVF8H3e_83iQ6umukg,4928
|
|
6
|
+
cogno_cortex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
cogno_cortex/registry.py,sha256=2rvzeCAVUoZlBE8TN18zi_bZ9xqr-hIbutNFNp9t7BM,3080
|
|
8
|
+
cogno_cortex/types.py,sha256=6VAtFJmqrzOtVns0sUXiMhLBJKBbBFFv8IevIwrcwFI,4731
|
|
9
|
+
cogno_cortex-0.1.0.dist-info/licenses/LICENSE,sha256=4cK96oGhr1hZsZT3Bo5cnKQ3mx6DJ0u8XuTtJ-TNuso,11340
|
|
10
|
+
cogno_cortex-0.1.0.dist-info/METADATA,sha256=L-gufCPTJ12lsx-UVPPSVsVnGikKk5RUpSPRp819jMo,6387
|
|
11
|
+
cogno_cortex-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
12
|
+
cogno_cortex-0.1.0.dist-info/top_level.txt,sha256=VmKptl32sT1wMSV5ysQ2xnGqKsyzZkKa75CFzzvhv54,13
|
|
13
|
+
cogno_cortex-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Sudoers AI
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cogno_cortex
|