AQIT
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
registry.py
Go to the documentation of this file.
1
# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2
# This file is part of the Aquin Engine. Unauthorized copying, modification,
3
# distribution, or use of this file, via any medium, is strictly prohibited.
4
# Proprietary and confidential. See LICENSE for terms.
5
6
from
__future__
import
annotations
7
8
from
typing
import
Any, Callable
9
10
TOOL_REGISTRY: dict[str, Callable] = {}
11
_TOOL_SCHEMAS: list[dict[str, Any]] = []
12
13
14
def
register
(name: str, schema: dict[str, Any] |
None
=
None
):
15
def
decorator(fn: Callable):
16
TOOL_REGISTRY[name] = fn
17
if
schema
is
not
None
:
18
_TOOL_SCHEMAS.append(schema)
19
return
fn
20
return
decorator
21
22
23
def
dispatch
(name: str, args: dict[str, Any], ctx: dict[str, Any]) -> Any:
24
handler = TOOL_REGISTRY.get(name)
25
if
handler
is
None
:
26
_load_stubs
()
27
handler = TOOL_REGISTRY.get(name)
28
if
handler
is
None
:
29
# Stale/partial registry (e.g. old daemon) — bridge may still have the handler.
30
from
aquin.compute.bridge
import
TOOL_ROUTES
31
32
if
name
in
TOOL_ROUTES:
33
from
.executor
import
execute_tool
34
35
return
execute_tool(name, args, ctx)
36
raise
NotImplementedError(f
"Tool '{name}' not yet ported to engine"
)
37
return
handler(args, ctx)
38
39
40
def
list_tools
() -> list[str]:
41
return
list(TOOL_REGISTRY.keys())
42
43
44
def
get_tool_schemas
() -> list[dict[str, Any]]:
45
return
list(_TOOL_SCHEMAS)
46
47
48
def
_load_stubs
() -> None:
49
from
.
import
executor
as
_executor
# noqa: F401 # must load before stubs
50
from
.
import
inspect
as
_inspect
# noqa: F401
51
from
.
import
session_memory
as
_session_memory
# noqa: F401
52
from
.
import
stubs
as
_stubs
# noqa: F401
53
_ = _executor, _inspect, _session_memory, _stubs
# silence unused warnings
54
55
_load_stubs
()
aquin.compute.bridge
Definition
bridge.py:1
aquin.engine.tools.registry.register
register(str name, dict[str, Any]|None schema=None)
Definition
registry.py:18
aquin.engine.tools.registry.dispatch
Any dispatch(str name, dict[str, Any] args, dict[str, Any] ctx)
Definition
registry.py:27
aquin.engine.tools.registry.list_tools
list[str] list_tools()
Definition
registry.py:44
aquin.engine.tools.registry._load_stubs
None _load_stubs()
Definition
registry.py:52
aquin.engine.tools.registry.get_tool_schemas
list[dict[str, Any]] get_tool_schemas()
Definition
registry.py:48
aquin
engine
tools
registry.py
AQIT · Aquin Labs Private Limited · Apache 2.0 · Generated by
1.18.0