@yahyahammad/venastine 0.2.0 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +9 -4
- package/CONFIG_ARCHITECTURE.md +2030 -0
- package/LICENSE +201 -201
- package/NOTICE +1 -1
- package/README.md +1034 -895
- package/agents/builtin/build.md +73 -0
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/general.md +80 -0
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -88
- package/agents/builtin/review.md +74 -74
- package/agents/builtin/test.md +65 -0
- package/agents/builtin/writer.md +67 -0
- package/agents/manager.py +68 -2
- package/agents/subagent_tool.py +472 -238
- package/agents/tui_commands.py +238 -151
- package/bin/venastine.mjs +150 -4
- package/bin/venastine.py +71 -0
- package/cli_commands.py +838 -0
- package/config.py +95 -1198
- package/config.yaml +1103 -0
- package/config_edit.py +1301 -0
- package/config_schema.py +971 -0
- package/config_update.py +749 -0
- package/core/agent_activity.py +256 -118
- package/core/ansi.py +452 -0
- package/core/approval.py +137 -115
- package/core/call_view.py +364 -0
- package/core/cancel.py +121 -0
- package/core/chatgpt_auth.py +747 -0
- package/core/claims_view.py +107 -0
- package/core/client.py +2715 -1559
- package/core/commands.py +460 -0
- package/core/compaction.py +1735 -971
- package/core/config_loader.py +1982 -1563
- package/core/connect.py +686 -0
- package/core/events.py +123 -61
- package/core/file_mentions.py +280 -0
- package/core/interaction.py +411 -328
- package/core/line_pattern.py +128 -0
- package/core/loop.py +2566 -1490
- package/core/memory.py +482 -370
- package/core/pipeline_models.py +190 -176
- package/core/provider_errors.py +234 -0
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -468
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/json_retry.py +19 -1
- package/core/reasoning/orchestrator.py +1561 -1382
- package/core/reasoning/output_writer.py +345 -286
- package/core/reasoning/payload_validation.py +524 -398
- package/core/reasoning/pipeline_storage.py +88 -22
- package/core/reasoning/review.py +659 -615
- package/core/reasoning/scholar.py +458 -434
- package/core/reasoning/source_corpus.py +433 -327
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -183
- package/core/session.py +36 -12
- package/core/session_view.py +259 -0
- package/core/session_wake.py +259 -0
- package/core/shell_sessions.py +1553 -0
- package/core/workspace_trust.py +1 -1
- package/credentials.py +148 -20
- package/database.py +333 -252
- package/{PRIVACY.md → docs/PRIVACY.md} +78 -66
- package/docs/SECURITY.md +108 -0
- package/docs/THIRD_PARTY_NOTICES.md +148 -0
- package/env_secrets.py +50 -9
- package/json_store.py +343 -123
- package/logging_setup.py +295 -185
- package/main.py +3433 -1961
- package/mcp_client/client.py +733 -499
- package/mcp_client/config.py +126 -21
- package/mcp_client/registration.py +343 -182
- package/memories/manager.py +147 -132
- package/memories/tui_commands.py +319 -244
- package/package.json +303 -73
- package/project_init/config_files.py +282 -278
- package/project_init/generator.py +728 -564
- package/project_init/manifest.py +18 -6
- package/project_init/tui_commands.py +147 -144
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +2 -0
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -262
- package/providers.json.example +4 -2
- package/pyproject.toml +149 -100
- package/requirements.txt +295 -72
- package/safety/policy_enforcement.py +1082 -746
- package/security/askpass.py +419 -0
- package/security/capability.py +207 -177
- package/security/confine.py +484 -0
- package/security/hosted.py +182 -0
- package/security/permissions.py +237 -190
- package/security/posture.py +124 -12
- package/security/protected_paths.py +501 -309
- package/security/sandbox.py +4108 -985
- package/security/secrets.py +855 -0
- package/skills/builtin/math/formal-specification.md +67 -67
- package/skills/builtin/math/numerical-methods.md +66 -66
- package/skills/builtin/research/experiment-design.md +62 -62
- package/skills/builtin/research/reproducibility.md +55 -55
- package/skills/builtin/research/source-evaluation.md +70 -70
- package/skills/builtin/research/statistical-inference.md +63 -63
- package/skills/builtin/research/technical-writing.md +59 -59
- package/skills/builtin/software/code-review.md +61 -61
- package/skills/builtin/software/debugging.md +61 -61
- package/skills/builtin/software/test-design.md +67 -67
- package/skills/tui_commands.py +110 -111
- package/storage.py +1338 -1005
- package/tools/base.py +161 -1
- package/tools/builtin/_math_common.py +667 -377
- package/tools/builtin/_net_common.py +225 -19
- package/tools/builtin/arxiv.py +497 -39
- package/tools/builtin/ask_user.py +231 -213
- package/tools/builtin/discrete_math.py +35 -4
- package/tools/builtin/fetch_url.py +371 -153
- package/tools/builtin/file_ops.py +720 -412
- package/tools/builtin/geometry.py +48 -12
- package/tools/builtin/get_time.py +2 -2
- package/tools/builtin/linear_algebra.py +66 -23
- package/tools/builtin/load_skill.py +76 -66
- package/tools/builtin/logic.py +171 -12
- package/tools/builtin/pin.py +227 -193
- package/tools/builtin/probability_stats.py +12 -16
- package/tools/builtin/project_docs.py +464 -405
- package/tools/builtin/remember.py +175 -158
- package/tools/builtin/shell.py +980 -461
- package/tools/builtin/shell_sessions.py +613 -0
- package/tools/builtin/symbolic_math.py +80 -10
- package/tools/builtin/todo.py +149 -147
- package/tools/builtin/web_search.py +191 -13
- package/tools/context.py +159 -136
- package/tools/isolation.py +107 -34
- package/tools/registry.py +1242 -925
- package/tui/app.py +8318 -4100
- package/tui/app.tcss +747 -556
- package/tui/commands.py +26 -170
- package/tui/diffs.py +34 -13
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +1329 -1279
- package/tui/meters.py +364 -268
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -943
- package/tui/themes.py +599 -559
- package/tui/widgets.py +3813 -2332
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
|
@@ -10,10 +10,16 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
from typing import Literal, Optional
|
|
12
12
|
|
|
13
|
-
from sympy.geometry import Point, Line, Circle, Polygon, Triangle
|
|
14
13
|
from pydantic import BaseModel, Field
|
|
14
|
+
from sympy.geometry import Circle, Line, Point, Polygon, Triangle
|
|
15
15
|
|
|
16
|
-
from tools.builtin._math_common import
|
|
16
|
+
from tools.builtin._math_common import (
|
|
17
|
+
MathParseError,
|
|
18
|
+
_split_warnings,
|
|
19
|
+
parse_params,
|
|
20
|
+
safe_parse,
|
|
21
|
+
serialize,
|
|
22
|
+
)
|
|
17
23
|
|
|
18
24
|
_OPERATIONS = Literal[
|
|
19
25
|
"distance", "midpoint", "is_collinear", "line_intersection",
|
|
@@ -31,6 +37,15 @@ class GeometryParams(BaseModel):
|
|
|
31
37
|
center: Optional[list[str]] = Field(None, description="Center point [x, y] for circle operations - optional, defaults to [0, 0] (origin) when omitted")
|
|
32
38
|
evaluate: bool = Field(False, description="If true, return numeric approximation (e.g. 12.566... instead of 4*pi). Default false keeps exact symbolic form.")
|
|
33
39
|
precision: int = Field(15, ge=1, le=50, description="Significant digits when evaluate is true")
|
|
40
|
+
symbols: Optional[list[str]] = Field(
|
|
41
|
+
None,
|
|
42
|
+
description=(
|
|
43
|
+
"Multi-character symbol names used in the coordinates or radius, "
|
|
44
|
+
"e.g. ['mass', 'width']. Declare them or they are read as "
|
|
45
|
+
"products of single letters: 'mass' becomes a*m*s**2. Single "
|
|
46
|
+
"letters and names containing an underscore are safe without this."
|
|
47
|
+
),
|
|
48
|
+
)
|
|
34
49
|
|
|
35
50
|
|
|
36
51
|
TOOL_SCHEMA = {
|
|
@@ -47,16 +62,28 @@ TOOL_SCHEMA = {
|
|
|
47
62
|
}
|
|
48
63
|
|
|
49
64
|
|
|
50
|
-
def _to_point(coords: list[str]) -> Point:
|
|
51
|
-
return Point(*[safe_parse(c
|
|
65
|
+
def _to_point(coords: list[str], symbols=None, rewritten=None) -> Point:
|
|
66
|
+
return Point(*[safe_parse(c, symbols=symbols, rewritten=rewritten)
|
|
67
|
+
for c in coords])
|
|
52
68
|
|
|
53
69
|
|
|
54
70
|
def run(params: dict) -> dict:
|
|
55
|
-
|
|
71
|
+
try:
|
|
72
|
+
parsed = parse_params(GeometryParams, params)
|
|
73
|
+
except MathParseError as e:
|
|
74
|
+
return {"error": str(e)}
|
|
75
|
+
# One `rewritten` set across every coordinate and the radius: this tool
|
|
76
|
+
# could not reach `symbols=` at all, so a multi-character coordinate was
|
|
77
|
+
# rewritten into a product of single letters (batch 131).
|
|
78
|
+
rewritten: set = set()
|
|
79
|
+
syms = parsed.symbols or None
|
|
80
|
+
|
|
81
|
+
def to_point(coords):
|
|
82
|
+
return _to_point(coords, syms, rewritten)
|
|
56
83
|
|
|
57
84
|
try:
|
|
58
85
|
op = parsed.operation
|
|
59
|
-
pts = [
|
|
86
|
+
pts = [to_point(p) for p in parsed.points] if parsed.points else []
|
|
60
87
|
|
|
61
88
|
if op == "distance":
|
|
62
89
|
if len(pts) < 2:
|
|
@@ -83,13 +110,13 @@ def run(params: dict) -> dict:
|
|
|
83
110
|
elif op == "circle_area":
|
|
84
111
|
if parsed.radius is None:
|
|
85
112
|
return {"error": "circle_area requires 'radius'."}
|
|
86
|
-
center =
|
|
87
|
-
result = Circle(center, safe_parse(parsed.radius)).area
|
|
113
|
+
center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
|
|
114
|
+
result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).area
|
|
88
115
|
elif op == "circle_circumference":
|
|
89
116
|
if parsed.radius is None:
|
|
90
117
|
return {"error": "circle_circumference requires 'radius'."}
|
|
91
|
-
center =
|
|
92
|
-
result = Circle(center, safe_parse(parsed.radius)).circumference
|
|
118
|
+
center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
|
|
119
|
+
result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).circumference
|
|
93
120
|
elif op == "polygon_area":
|
|
94
121
|
if len(pts) < 3:
|
|
95
122
|
return {"error": f"polygon_area requires at least 3 points (got {len(pts)})."}
|
|
@@ -143,6 +170,15 @@ def run(params: dict) -> dict:
|
|
|
143
170
|
elif hasattr(result, "evalf"):
|
|
144
171
|
result = result.evalf(parsed.precision)
|
|
145
172
|
except Exception:
|
|
146
|
-
pass
|
|
173
|
+
pass # no numeric form; the exact result is still a correct answer
|
|
147
174
|
|
|
148
|
-
|
|
175
|
+
# H6, one batch late (batch 143). The evaluate block above stays where it is: a tail
|
|
176
|
+
# handler contains the one call that can fail without restructuring the
|
|
177
|
+
# function around it, which is `discrete_math`'s shape.
|
|
178
|
+
try:
|
|
179
|
+
out: dict = {"result": serialize(result, what=op), "operation": op}
|
|
180
|
+
except MathParseError as e:
|
|
181
|
+
return {"error": str(e)}
|
|
182
|
+
if rewritten:
|
|
183
|
+
out["warnings"] = _split_warnings(rewritten)
|
|
184
|
+
return out
|
|
@@ -6,7 +6,7 @@ grounding "as of today" or "current events" style claims during research
|
|
|
6
6
|
passes without needing a network call.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from datetime import
|
|
9
|
+
from datetime import UTC, datetime
|
|
10
10
|
|
|
11
11
|
TOOL_SCHEMA = {
|
|
12
12
|
"name": "get_time",
|
|
@@ -16,5 +16,5 @@ TOOL_SCHEMA = {
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def run(params: dict) -> dict:
|
|
19
|
-
now = datetime.now(
|
|
19
|
+
now = datetime.now(UTC)
|
|
20
20
|
return {"utc_datetime": now.isoformat()}
|
|
@@ -13,7 +13,13 @@ from typing import Literal, Optional
|
|
|
13
13
|
import sympy
|
|
14
14
|
from pydantic import BaseModel, Field
|
|
15
15
|
|
|
16
|
-
from tools.builtin._math_common import
|
|
16
|
+
from tools.builtin._math_common import (
|
|
17
|
+
MathParseError,
|
|
18
|
+
_split_warnings,
|
|
19
|
+
parse_params,
|
|
20
|
+
safe_parse,
|
|
21
|
+
serialize,
|
|
22
|
+
)
|
|
17
23
|
|
|
18
24
|
_OPERATIONS = Literal[
|
|
19
25
|
"add", "subtract", "multiply", "transpose", "determinant",
|
|
@@ -33,6 +39,15 @@ class LinearAlgebraParams(BaseModel):
|
|
|
33
39
|
vector_a: Optional[list[str]] = Field(None, description="First vector -- needed for dot_product/cross_product/norm")
|
|
34
40
|
vector_b: Optional[list[str]] = Field(None, description="Second vector -- needed for dot_product/cross_product")
|
|
35
41
|
scalar: Optional[str] = Field(None, description="Scalar value, for scalar multiplication of matrix_a")
|
|
42
|
+
symbols: Optional[list[str]] = Field(
|
|
43
|
+
None,
|
|
44
|
+
description=(
|
|
45
|
+
"Multi-character symbol names used in the entries, e.g. "
|
|
46
|
+
"['mass', 'velocity']. Declare them or they are read as products "
|
|
47
|
+
"of single letters: 'mass' becomes a*m*s**2. Single letters and "
|
|
48
|
+
"names containing an underscore are safe without this."
|
|
49
|
+
),
|
|
50
|
+
)
|
|
36
51
|
|
|
37
52
|
|
|
38
53
|
TOOL_SCHEMA = {
|
|
@@ -49,16 +64,33 @@ TOOL_SCHEMA = {
|
|
|
49
64
|
}
|
|
50
65
|
|
|
51
66
|
|
|
52
|
-
def _to_matrix(rows: list[list[str]]) -> sympy.Matrix:
|
|
53
|
-
return sympy.Matrix([[safe_parse(cell
|
|
67
|
+
def _to_matrix(rows: list[list[str]], symbols=None, rewritten=None) -> sympy.Matrix:
|
|
68
|
+
return sympy.Matrix([[safe_parse(cell, symbols=symbols, rewritten=rewritten)
|
|
69
|
+
for cell in row] for row in rows])
|
|
54
70
|
|
|
55
71
|
|
|
56
|
-
def _to_vector(values: list[str]) -> sympy.Matrix:
|
|
57
|
-
return sympy.Matrix([safe_parse(v
|
|
72
|
+
def _to_vector(values: list[str], symbols=None, rewritten=None) -> sympy.Matrix:
|
|
73
|
+
return sympy.Matrix([safe_parse(v, symbols=symbols, rewritten=rewritten)
|
|
74
|
+
for v in values])
|
|
58
75
|
|
|
59
76
|
|
|
60
77
|
def run(params: dict) -> dict:
|
|
61
|
-
|
|
78
|
+
try:
|
|
79
|
+
parsed = parse_params(LinearAlgebraParams, params)
|
|
80
|
+
except MathParseError as e:
|
|
81
|
+
return {"error": str(e)}
|
|
82
|
+
# EVERY parsed field gets `symbols` and shares one `rewritten` set: this
|
|
83
|
+
# tool had no way to reach `symbols=` at all, so a multi-character entry
|
|
84
|
+
# was silently rewritten into a product of single letters and the answer
|
|
85
|
+
# named a different quantity (batch 131).
|
|
86
|
+
rewritten: set = set()
|
|
87
|
+
syms = parsed.symbols or None
|
|
88
|
+
|
|
89
|
+
def to_matrix(rows):
|
|
90
|
+
return _to_matrix(rows, syms, rewritten)
|
|
91
|
+
|
|
92
|
+
def to_vector(values):
|
|
93
|
+
return _to_vector(values, syms, rewritten)
|
|
62
94
|
|
|
63
95
|
try:
|
|
64
96
|
op = parsed.operation
|
|
@@ -66,80 +98,81 @@ def run(params: dict) -> dict:
|
|
|
66
98
|
if op == "add":
|
|
67
99
|
if parsed.matrix_a is None or parsed.matrix_b is None:
|
|
68
100
|
return {"error": "add requires 'matrix_a' and 'matrix_b' (each a list of rows)."}
|
|
69
|
-
result =
|
|
101
|
+
result = to_matrix(parsed.matrix_a) + to_matrix(parsed.matrix_b)
|
|
70
102
|
elif op == "subtract":
|
|
71
103
|
if parsed.matrix_a is None or parsed.matrix_b is None:
|
|
72
104
|
return {"error": "subtract requires 'matrix_a' and 'matrix_b' (each a list of rows)."}
|
|
73
|
-
result =
|
|
105
|
+
result = to_matrix(parsed.matrix_a) - to_matrix(parsed.matrix_b)
|
|
74
106
|
elif op == "multiply":
|
|
75
107
|
if parsed.matrix_a is None:
|
|
76
108
|
return {"error": "multiply requires 'matrix_a'."}
|
|
77
|
-
a =
|
|
109
|
+
a = to_matrix(parsed.matrix_a)
|
|
78
110
|
if parsed.scalar is not None:
|
|
79
|
-
result = safe_parse(parsed.scalar
|
|
111
|
+
result = safe_parse(parsed.scalar, symbols=syms,
|
|
112
|
+
rewritten=rewritten) * a
|
|
80
113
|
else:
|
|
81
114
|
if parsed.matrix_b is None:
|
|
82
115
|
return {"error": "multiply requires 'matrix_b' or 'scalar'."}
|
|
83
|
-
result = a *
|
|
116
|
+
result = a * to_matrix(parsed.matrix_b)
|
|
84
117
|
elif op == "transpose":
|
|
85
118
|
if parsed.matrix_a is None:
|
|
86
119
|
return {"error": "transpose requires 'matrix_a'."}
|
|
87
|
-
result =
|
|
120
|
+
result = to_matrix(parsed.matrix_a).T
|
|
88
121
|
elif op == "determinant":
|
|
89
122
|
if parsed.matrix_a is None:
|
|
90
123
|
return {"error": "determinant requires 'matrix_a'."}
|
|
91
|
-
m =
|
|
124
|
+
m = to_matrix(parsed.matrix_a)
|
|
92
125
|
if m.rows != m.cols:
|
|
93
126
|
return {"error": f"determinant requires a square matrix (got {m.rows}x{m.cols})."}
|
|
94
127
|
result = m.det()
|
|
95
128
|
elif op == "inverse":
|
|
96
129
|
if parsed.matrix_a is None:
|
|
97
130
|
return {"error": "inverse requires 'matrix_a'."}
|
|
98
|
-
m =
|
|
131
|
+
m = to_matrix(parsed.matrix_a)
|
|
99
132
|
if m.rows != m.cols:
|
|
100
133
|
return {"error": f"inverse requires a square matrix (got {m.rows}x{m.cols})."}
|
|
101
134
|
result = m.inv()
|
|
102
135
|
elif op == "eigenvalues":
|
|
103
136
|
if parsed.matrix_a is None:
|
|
104
137
|
return {"error": "eigenvalues requires 'matrix_a'."}
|
|
105
|
-
m =
|
|
138
|
+
m = to_matrix(parsed.matrix_a)
|
|
106
139
|
if m.rows != m.cols:
|
|
107
140
|
return {"error": f"eigenvalues requires a square matrix (got {m.rows}x{m.cols})."}
|
|
108
141
|
result = m.eigenvals()
|
|
109
142
|
elif op == "eigenvectors":
|
|
110
143
|
if parsed.matrix_a is None:
|
|
111
144
|
return {"error": "eigenvectors requires 'matrix_a'."}
|
|
112
|
-
m =
|
|
145
|
+
m = to_matrix(parsed.matrix_a)
|
|
113
146
|
if m.rows != m.cols:
|
|
114
147
|
return {"error": f"eigenvectors requires a square matrix (got {m.rows}x{m.cols})."}
|
|
115
148
|
result = m.eigenvects()
|
|
116
149
|
elif op == "rank":
|
|
117
150
|
if parsed.matrix_a is None:
|
|
118
151
|
return {"error": "rank requires 'matrix_a'."}
|
|
119
|
-
result =
|
|
152
|
+
result = to_matrix(parsed.matrix_a).rank()
|
|
120
153
|
elif op == "solve_linear_system":
|
|
121
154
|
if parsed.matrix_a is None or parsed.matrix_b is None:
|
|
122
155
|
return {"error": "solve_linear_system requires 'matrix_a' and 'matrix_b' (b as column vector/matrix with same rows as A, e.g. [[7],[5]])."}
|
|
123
|
-
a =
|
|
124
|
-
b =
|
|
156
|
+
a = to_matrix(parsed.matrix_a)
|
|
157
|
+
b = to_matrix(parsed.matrix_b)
|
|
125
158
|
if a.rows != b.rows:
|
|
126
159
|
return {"error": f"solve_linear_system: 'matrix_b' has {b.rows} rows but 'matrix_a' has {a.rows} — b must be a column vector/matrix with the same number of rows as A (e.g. [[7],[5]] for a 2-row system)."}
|
|
127
160
|
result = a.solve(b)
|
|
128
161
|
elif op == "dot_product":
|
|
129
162
|
if parsed.vector_a is None or parsed.vector_b is None:
|
|
130
163
|
return {"error": "dot_product requires 'vector_a' and 'vector_b'."}
|
|
131
|
-
result =
|
|
164
|
+
result = to_vector(parsed.vector_a).dot(to_vector(parsed.vector_b))
|
|
132
165
|
elif op == "cross_product":
|
|
133
166
|
if parsed.vector_a is None or parsed.vector_b is None:
|
|
134
167
|
return {"error": "cross_product requires 'vector_a' and 'vector_b'."}
|
|
135
|
-
va, vb =
|
|
168
|
+
va, vb = to_vector(parsed.vector_a), to_vector(parsed.vector_b)
|
|
136
169
|
if len(va) != 3 or len(vb) != 3:
|
|
137
170
|
return {"error": "cross_product requires 3-dimensional vectors"}
|
|
138
171
|
result = va.cross(vb)
|
|
139
172
|
elif op == "norm":
|
|
140
173
|
if parsed.vector_a is None:
|
|
141
174
|
return {"error": "norm requires 'vector_a'."}
|
|
142
|
-
result =
|
|
175
|
+
result = to_vector(parsed.vector_a).norm()
|
|
143
176
|
else:
|
|
144
177
|
return {"error": f"Unknown operation: {op}"}
|
|
145
178
|
|
|
@@ -152,4 +185,14 @@ def run(params: dict) -> dict:
|
|
|
152
185
|
return {"error": "Computation failed: determinant/inverse/eigen requires a square matrix — the supplied matrix is not square."}
|
|
153
186
|
return {"error": f"Computation failed: {e}"}
|
|
154
187
|
|
|
155
|
-
|
|
188
|
+
# H6, one batch late (batch 143). `determinant([["factorial(3000)","0"],["0","1"]])` is a
|
|
189
|
+
# correct answer this call could not print, and the ValueError left
|
|
190
|
+
# `run()` for dispatch's containment -- the branch reserved for a real
|
|
191
|
+
# bug. See `_math_common.serialize`.
|
|
192
|
+
try:
|
|
193
|
+
out: dict = {"result": serialize(result, what=op), "operation": op}
|
|
194
|
+
except MathParseError as e:
|
|
195
|
+
return {"error": str(e)}
|
|
196
|
+
if rewritten:
|
|
197
|
+
out["warnings"] = _split_warnings(rewritten)
|
|
198
|
+
return out
|
|
@@ -1,66 +1,76 @@
|
|
|
1
|
-
"""
|
|
2
|
-
tools/builtin/load_skill.py
|
|
3
|
-
|
|
4
|
-
Skill progressive disclosure (ROADMAP_v2 §14): the model's system prompt
|
|
5
|
-
lists available skills as name + one-line description only; this tool
|
|
6
|
-
returns a skill's full body on request. View-only -- activation
|
|
7
|
-
semantics (additional_tools, slash commands) belong to §19's
|
|
8
|
-
SkillManager, not here.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from core import config_loader
|
|
12
|
-
|
|
13
|
-
TOOL_SCHEMA = {
|
|
14
|
-
"name": "load_skill",
|
|
15
|
-
"description": "View the full instructions of an available skill. "
|
|
16
|
-
"The system prompt lists available skills by name and "
|
|
17
|
-
"one-line summary; call this with a skill name to load "
|
|
18
|
-
"its complete methodology before following it.",
|
|
19
|
-
"input_schema": {
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"name": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "Skill name exactly as listed in the "
|
|
25
|
-
"Available skills catalog.",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
"required": ["name"],
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def has_skills() -> bool:
|
|
34
|
-
"""ToolSpec.available_check (ROADMAP_v2 §15, review finding F5).
|
|
35
|
-
|
|
36
|
-
With no skills discovered -- or before config_loader.initialize() has
|
|
37
|
-
run at all -- the system prompt carries no catalog, so this tool's
|
|
38
|
-
only possible answer is "Unknown skill". Advertising it anyway is the
|
|
39
|
-
same defect shape as the fetch_url one §15 exists to fix: a schema the
|
|
40
|
-
model can see, choose, and never get value from. Returning False here
|
|
41
|
-
keeps it out of registry.schemas() until there is something to load.
|
|
42
|
-
|
|
43
|
-
Reads the SAME function prompt assembly uses (skill_catalog_text, via
|
|
44
|
-
prompts/system_prompts.with_skill_catalog) rather than a parallel
|
|
45
|
-
check, so "advertised" and "catalogued" cannot drift apart.
|
|
46
|
-
"""
|
|
47
|
-
return bool(config_loader.skill_catalog_text())
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def run(params: dict) -> dict:
|
|
51
|
-
# params.get, not params[]. NO provider validates tool inputs against
|
|
52
|
-
# the schema, so a call with the key missing or misspelled raised a
|
|
53
|
-
# bare KeyError -- and _run() catches only ToolCallDenied, so it
|
|
54
|
-
# aborted the whole turn, skipped any remaining batched tool calls,
|
|
55
|
-
# and persisted no tool_result for the tool_use id. An error dict
|
|
56
|
-
# lets the model see what it got wrong and correct itself, which is
|
|
57
|
-
# what the unknown-name branch two lines down already does.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
"""
|
|
2
|
+
tools/builtin/load_skill.py
|
|
3
|
+
|
|
4
|
+
Skill progressive disclosure (ROADMAP_v2 §14): the model's system prompt
|
|
5
|
+
lists available skills as name + one-line description only; this tool
|
|
6
|
+
returns a skill's full body on request. View-only -- activation
|
|
7
|
+
semantics (additional_tools, slash commands) belong to §19's
|
|
8
|
+
SkillManager, not here.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from core import config_loader
|
|
12
|
+
|
|
13
|
+
TOOL_SCHEMA = {
|
|
14
|
+
"name": "load_skill",
|
|
15
|
+
"description": "View the full instructions of an available skill. "
|
|
16
|
+
"The system prompt lists available skills by name and "
|
|
17
|
+
"one-line summary; call this with a skill name to load "
|
|
18
|
+
"its complete methodology before following it.",
|
|
19
|
+
"input_schema": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"name": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Skill name exactly as listed in the "
|
|
25
|
+
"Available skills catalog.",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
"required": ["name"],
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def has_skills() -> bool:
|
|
34
|
+
"""ToolSpec.available_check (ROADMAP_v2 §15, review finding F5).
|
|
35
|
+
|
|
36
|
+
With no skills discovered -- or before config_loader.initialize() has
|
|
37
|
+
run at all -- the system prompt carries no catalog, so this tool's
|
|
38
|
+
only possible answer is "Unknown skill". Advertising it anyway is the
|
|
39
|
+
same defect shape as the fetch_url one §15 exists to fix: a schema the
|
|
40
|
+
model can see, choose, and never get value from. Returning False here
|
|
41
|
+
keeps it out of registry.schemas() until there is something to load.
|
|
42
|
+
|
|
43
|
+
Reads the SAME function prompt assembly uses (skill_catalog_text, via
|
|
44
|
+
prompts/system_prompts.with_skill_catalog) rather than a parallel
|
|
45
|
+
check, so "advertised" and "catalogued" cannot drift apart.
|
|
46
|
+
"""
|
|
47
|
+
return bool(config_loader.skill_catalog_text())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def run(params: dict) -> dict:
|
|
51
|
+
# params.get, not params[]. NO provider validates tool inputs against
|
|
52
|
+
# the schema, so a call with the key missing or misspelled raised a
|
|
53
|
+
# bare KeyError -- and _run() catches only ToolCallDenied, so it
|
|
54
|
+
# aborted the whole turn, skipped any remaining batched tool calls,
|
|
55
|
+
# and persisted no tool_result for the tool_use id. An error dict
|
|
56
|
+
# lets the model see what it got wrong and correct itself, which is
|
|
57
|
+
# what the unknown-name branch two lines down already does.
|
|
58
|
+
#
|
|
59
|
+
# THE ONE OF THESE WRITTEN IN THE PAST TENSE, and therefore the one
|
|
60
|
+
# that stayed true: four siblings said the same thing in the PRESENT
|
|
61
|
+
# tense, and dispatch() has contained a handler's exception since
|
|
62
|
+
# well before they were written. The last two clauses are the
|
|
63
|
+
# precise ones -- the parallel path converts a raise into THIS call's
|
|
64
|
+
# error result so the siblings' finished work and the tool_use id's
|
|
65
|
+
# reply both survive. tools/base.py carries the one copy of all of it
|
|
66
|
+
# now, including the half none of these mentioned: a GATE's raise is
|
|
67
|
+
# not contained (batch 146).
|
|
68
|
+
name = params.get("name")
|
|
69
|
+
if not name:
|
|
70
|
+
return {"error": "load_skill requires a 'name' -- the skill's name "
|
|
71
|
+
"exactly as listed in the available skills catalog."}
|
|
72
|
+
skill = config_loader.get_skill(name)
|
|
73
|
+
if skill is None:
|
|
74
|
+
return {"error": f"Unknown skill: {name!r} is not in "
|
|
75
|
+
f"the available skills catalog."}
|
|
76
|
+
return {"result": skill.body}
|