agentnik 0.11.1__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.
- agentnik/__init__.py +2 -0
- agentnik/analysis_tools.py +106 -0
- agentnik/assets/agentnik-dark-old.png +0 -0
- agentnik/assets/agentnik-dark.png +0 -0
- agentnik/assets/agentnik-dark.svg +1 -0
- agentnik/assets/agentnik-icon.ico +0 -0
- agentnik/assets/agentnik-icon.png +0 -0
- agentnik/assets/agentnik-icon.svg +1 -0
- agentnik/assets/agentnik-light-old.png +0 -0
- agentnik/assets/agentnik-light.png +0 -0
- agentnik/assets/agentnik-light.svg +1 -0
- agentnik/chat_image.py +50 -0
- agentnik/chat_mcp.py +415 -0
- agentnik/citations.py +28 -0
- agentnik/code_agent.py +2030 -0
- agentnik/code_artifacts.py +59 -0
- agentnik/code_image.py +80 -0
- agentnik/code_limits.py +40 -0
- agentnik/code_search.py +126 -0
- agentnik/code_symbols.py +41 -0
- agentnik/code_ui.py +1785 -0
- agentnik/code_vision.py +51 -0
- agentnik/coding.py +6 -0
- agentnik/compat_tools.py +160 -0
- agentnik/context_compaction.py +106 -0
- agentnik/context_usage.py +42 -0
- agentnik/core.py +421 -0
- agentnik/decision_advice.py +44 -0
- agentnik/directory_ops.py +26 -0
- agentnik/document_outline.py +125 -0
- agentnik/document_reader.py +134 -0
- agentnik/document_ui.py +53 -0
- agentnik/failures.py +58 -0
- agentnik/git_credentials.py +32 -0
- agentnik/git_service.py +529 -0
- agentnik/hosted.py +119 -0
- agentnik/image_generation.py +147 -0
- agentnik/image_settings.py +11 -0
- agentnik/independent_review.py +146 -0
- agentnik/localization.py +38 -0
- agentnik/managed_symbols.py +74 -0
- agentnik/mcp_2026.py +94 -0
- agentnik/mcp_2026_tasks.py +86 -0
- agentnik/mcp_code.py +210 -0
- agentnik/mcp_completion.py +34 -0
- agentnik/mcp_content.py +127 -0
- agentnik/mcp_elicitation.py +351 -0
- agentnik/mcp_fallback.py +49 -0
- agentnik/mcp_local.py +597 -0
- agentnik/mcp_oauth.py +59 -0
- agentnik/mcp_oauth_credentials.py +162 -0
- agentnik/mcp_oauth_discovery.py +105 -0
- agentnik/mcp_oauth_flow.py +177 -0
- agentnik/mcp_prompts.py +75 -0
- agentnik/mcp_remote.py +961 -0
- agentnik/mcp_resources.py +234 -0
- agentnik/mcp_schema.py +331 -0
- agentnik/mcp_support.py +223 -0
- agentnik/mcp_ui.py +457 -0
- agentnik/ollama_tools.py +129 -0
- agentnik/page_fetch.py +89 -0
- agentnik/parallel_tools.py +100 -0
- agentnik/project_memory.py +73 -0
- agentnik/project_skills.py +158 -0
- agentnik/project_tools.py +128 -0
- agentnik/repositories.py +80 -0
- agentnik/repository_guidance.py +53 -0
- agentnik/research.py +487 -0
- agentnik/research_settings.py +51 -0
- agentnik/research_ui.py +178 -0
- agentnik/responses_tools.py +280 -0
- agentnik/retention.py +31 -0
- agentnik/routing.py +134 -0
- agentnik/script_symbols.py +68 -0
- agentnik/search_cache.py +41 -0
- agentnik/search_providers.py +27 -0
- agentnik/selection_scroll.py +49 -0
- agentnik/sessions.py +264 -0
- agentnik/shell.py +107 -0
- agentnik/storage.py +270 -0
- agentnik/subagent_capabilities.py +34 -0
- agentnik/subagent_outputs.py +80 -0
- agentnik/subagent_status.py +18 -0
- agentnik/systems_symbols.py +71 -0
- agentnik/task_plan.py +31 -0
- agentnik/test_reports.py +40 -0
- agentnik/tls.py +34 -0
- agentnik/tools.py +294 -0
- agentnik/track_authoring.py +64 -0
- agentnik/track_drafting.py +77 -0
- agentnik/track_editing.py +50 -0
- agentnik/track_execution.py +79 -0
- agentnik/track_reconciliation.py +64 -0
- agentnik/tracks.py +90 -0
- agentnik/translations/agentnik_de.qm +0 -0
- agentnik/translations/agentnik_de.ts +5297 -0
- agentnik/translations/agentnik_es-MX.qm +0 -0
- agentnik/translations/agentnik_es-MX.ts +5297 -0
- agentnik/translations/agentnik_fr-CA.qm +0 -0
- agentnik/translations/agentnik_fr-CA.ts +5297 -0
- agentnik/translations/agentnik_ko.qm +0 -0
- agentnik/translations/agentnik_ko.ts +5345 -0
- agentnik/translations/agentnik_zh-Hans.qm +0 -0
- agentnik/translations/agentnik_zh-Hans.ts +5297 -0
- agentnik/translations/agentnik_zh-Hant.qm +0 -0
- agentnik/translations/agentnik_zh-Hant.ts +5297 -0
- agentnik/ui.py +1576 -0
- agentnik/web.py +539 -0
- agentnik-0.11.1.dist-info/METADATA +85 -0
- agentnik-0.11.1.dist-info/RECORD +114 -0
- agentnik-0.11.1.dist-info/WHEEL +5 -0
- agentnik-0.11.1.dist-info/entry_points.txt +2 -0
- agentnik-0.11.1.dist-info/licenses/LICENSE +204 -0
- agentnik-0.11.1.dist-info/top_level.txt +1 -0
agentnik/__init__.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Pure bounded numeric tools: no eval, imports, filesystem, or network execution."""
|
|
2
|
+
import ast
|
|
3
|
+
import csv
|
|
4
|
+
import io
|
|
5
|
+
import json
|
|
6
|
+
import math
|
|
7
|
+
import operator
|
|
8
|
+
import statistics
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AnalysisError(ValueError):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def finite(value):
|
|
16
|
+
if type(value) not in (int, float) or not math.isfinite(value) or abs(value) > 1e100:
|
|
17
|
+
raise AnalysisError('Result is non-finite or exceeds magnitude 1e100.')
|
|
18
|
+
return value
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def calculate(expression):
|
|
22
|
+
if not isinstance(expression, str) or not 0 < len(expression) <= 1000:
|
|
23
|
+
raise AnalysisError('Expression must contain 1–1000 characters.')
|
|
24
|
+
ops = {ast.Add:operator.add, ast.Sub:operator.sub, ast.Mult:operator.mul, ast.Div:operator.truediv, ast.FloorDiv:operator.floordiv, ast.Mod:operator.mod, ast.Pow:operator.pow}
|
|
25
|
+
funcs = {'abs':abs, 'round':round, 'min':min, 'max':max, 'sqrt':math.sqrt, 'log':math.log, 'log10':math.log10, 'sin':math.sin, 'cos':math.cos, 'tan':math.tan, 'ceil':math.ceil, 'floor':math.floor}
|
|
26
|
+
try:
|
|
27
|
+
tree = ast.parse(expression, mode='eval')
|
|
28
|
+
if sum(1 for _ in ast.walk(tree)) > 120: raise AnalysisError('Expression is too complex.')
|
|
29
|
+
def visit(node, depth=0):
|
|
30
|
+
if depth > 20: raise AnalysisError('Expression nesting exceeds 20.')
|
|
31
|
+
if isinstance(node, ast.Constant): return finite(node.value)
|
|
32
|
+
if isinstance(node, ast.Name) and node.id in ('pi', 'e'): return getattr(math, node.id)
|
|
33
|
+
if isinstance(node, ast.UnaryOp) and isinstance(node.op, (ast.UAdd, ast.USub)):
|
|
34
|
+
value = visit(node.operand, depth+1); return finite(-value if isinstance(node.op, ast.USub) else value)
|
|
35
|
+
if isinstance(node, ast.BinOp) and type(node.op) in ops:
|
|
36
|
+
left, right = visit(node.left, depth+1), visit(node.right, depth+1)
|
|
37
|
+
if isinstance(node.op, ast.Pow) and abs(right) > 100: raise AnalysisError('Exponent magnitude exceeds 100.')
|
|
38
|
+
return finite(ops[type(node.op)](left, right))
|
|
39
|
+
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id in funcs and not node.keywords and 1 <= len(node.args) <= 20:
|
|
40
|
+
return finite(funcs[node.func.id](*[visit(arg, depth+1) for arg in node.args]))
|
|
41
|
+
raise AnalysisError('Only numeric arithmetic and documented math functions are allowed.')
|
|
42
|
+
return {'expression':expression, 'value':visit(tree.body), 'precision':'Python integer / IEEE-754 float; approximate for non-integer arithmetic'}
|
|
43
|
+
except AnalysisError: raise
|
|
44
|
+
except (ValueError, TypeError, ArithmeticError, SyntaxError, RecursionError):
|
|
45
|
+
raise AnalysisError('Invalid arithmetic, function arguments, or numeric domain.') from None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def analyze_data(data):
|
|
49
|
+
"""data is a JSON request containing format, content, optional group_by."""
|
|
50
|
+
if not isinstance(data, str) or len(data.encode()) > 16000: raise AnalysisError('Data request exceeds 16 KB.')
|
|
51
|
+
try:
|
|
52
|
+
request = json.loads(data)
|
|
53
|
+
if not isinstance(request, dict) or set(request) - {'format','content','group_by'} or not {'format','content'} <= set(request): raise AnalysisError('Use format, content, and optional group_by.')
|
|
54
|
+
content = request['content']; kind = request['format']
|
|
55
|
+
if not isinstance(content, str): raise AnalysisError('content must be a string.')
|
|
56
|
+
if kind == 'csv':
|
|
57
|
+
reader = csv.reader(io.StringIO(content)); headers = next(reader, [])
|
|
58
|
+
if not headers or len(headers) > 32 or len(set(headers)) != len(headers) or any(not h or len(h)>100 for h in headers): raise AnalysisError('CSV requires 1–32 unique nonempty column headers (up to 100 characters).')
|
|
59
|
+
rows = []
|
|
60
|
+
for values in reader:
|
|
61
|
+
if len(values) != len(headers): raise AnalysisError('CSV row width does not match headers.')
|
|
62
|
+
rows.append(dict(zip(headers, values)))
|
|
63
|
+
if len(rows)>1000: raise AnalysisError('At most 1000 rows are supported.')
|
|
64
|
+
elif kind == 'json':
|
|
65
|
+
rows = json.loads(content)
|
|
66
|
+
if not isinstance(rows,list) or not rows or len(rows)>1000 or any(not isinstance(r,dict) for r in rows): raise AnalysisError('JSON content must be 1–1000 row objects.')
|
|
67
|
+
headers = list(dict.fromkeys(key for row in rows for key in row))
|
|
68
|
+
if not 1<=len(headers)<=32 or any(not key or len(key)>100 for key in headers): raise AnalysisError('Use 1–32 nonempty column names (up to 100 characters).')
|
|
69
|
+
if any(type(v) not in (str,int,float,bool,type(None)) for row in rows for v in row.values()): raise AnalysisError('Nested JSON cells are not supported.')
|
|
70
|
+
else: raise AnalysisError('format must be csv or json.')
|
|
71
|
+
if not rows: raise AnalysisError('No data rows.')
|
|
72
|
+
def summary(selected):
|
|
73
|
+
result = {}
|
|
74
|
+
for column in headers:
|
|
75
|
+
numbers=[];missing=other=0
|
|
76
|
+
for row in selected:
|
|
77
|
+
value=row.get(column)
|
|
78
|
+
if value is None or isinstance(value,str) and not value.strip(): missing+=1;continue
|
|
79
|
+
try:
|
|
80
|
+
if isinstance(value,bool):raise ValueError()
|
|
81
|
+
number=float(value)
|
|
82
|
+
if not math.isfinite(number) or abs(number)>1e100:raise ValueError()
|
|
83
|
+
numbers.append(number)
|
|
84
|
+
except (ValueError,TypeError,OverflowError):other+=1
|
|
85
|
+
item={'numeric_count':len(numbers),'missing_count':missing,'nonnumeric_count':other}
|
|
86
|
+
if numbers:
|
|
87
|
+
item.update(min=min(numbers),max=max(numbers),sum=math.fsum(numbers),mean=statistics.fmean(numbers),median=statistics.median(numbers),sample_stdev=statistics.stdev(numbers) if len(numbers)>1 else None)
|
|
88
|
+
result[column]=item
|
|
89
|
+
return result
|
|
90
|
+
result={'rows':len(rows),'columns':summary(rows),'notice':'Statistics use finite numeric cells only; booleans and invalid numbers count as nonnumeric. Missing cells are excluded. Float arithmetic is approximate.'}
|
|
91
|
+
if 'group_by' in request:
|
|
92
|
+
column=request['group_by']
|
|
93
|
+
if not isinstance(column,str) or column not in headers:raise AnalysisError('group_by must name an existing column.')
|
|
94
|
+
groups={}
|
|
95
|
+
for row in rows:
|
|
96
|
+
value=row.get(column); key=json.dumps(value,ensure_ascii=False,allow_nan=False)
|
|
97
|
+
groups.setdefault(key,[]).append(row)
|
|
98
|
+
if len(groups)>10:raise AnalysisError('Grouping supports at most 10 distinct values.')
|
|
99
|
+
result['groups']=[{'value':json.loads(key),'rows':len(selected),'columns':summary(selected)} for key,selected in groups.items()]
|
|
100
|
+
if len(json.dumps(result,allow_nan=False).encode())>24000:raise AnalysisError('Analysis output exceeds 24 KB; select fewer columns or groups.')
|
|
101
|
+
return result
|
|
102
|
+
except AnalysisError:raise
|
|
103
|
+
except (ValueError,TypeError,OverflowError,csv.Error,RecursionError):raise AnalysisError('Invalid CSV/JSON data request.') from None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
HANDLERS={'calculate':calculate,'analyze_data':analyze_data}
|
|
Binary file
|
|
Binary file
|