unique_toolkit 2026.46.0.dev9__py3-none-any.whl → 2026.46.0.dev11__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.
- unique_toolkit/_common/utils/jinja/sandbox.py +40 -2
- unique_toolkit/agentic/tools/mcp/tool_wrapper.py +2 -0
- unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/artifacts.py +3 -1
- unique_toolkit/content/constants.py +4 -0
- {unique_toolkit-2026.46.0.dev9.dist-info → unique_toolkit-2026.46.0.dev11.dist-info}/METADATA +1 -1
- {unique_toolkit-2026.46.0.dev9.dist-info → unique_toolkit-2026.46.0.dev11.dist-info}/RECORD +7 -7
- {unique_toolkit-2026.46.0.dev9.dist-info → unique_toolkit-2026.46.0.dev11.dist-info}/WHEEL +0 -0
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
from functools import cache
|
|
2
2
|
|
|
3
|
-
from jinja2 import Template
|
|
4
|
-
from jinja2.
|
|
3
|
+
from jinja2 import Template, TemplateError, nodes
|
|
4
|
+
from jinja2.exceptions import SecurityError
|
|
5
|
+
from jinja2.sandbox import (
|
|
6
|
+
UNSAFE_ASYNC_GENERATOR_ATTRIBUTES,
|
|
7
|
+
UNSAFE_COROUTINE_ATTRIBUTES,
|
|
8
|
+
UNSAFE_FUNCTION_ATTRIBUTES,
|
|
9
|
+
UNSAFE_GENERATOR_ATTRIBUTES,
|
|
10
|
+
UNSAFE_METHOD_ATTRIBUTES,
|
|
11
|
+
SandboxedEnvironment,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = ["TemplateError", "sandboxed_template", "validate_sandboxed_template"]
|
|
15
|
+
|
|
16
|
+
_UNSAFE_STATIC_ATTRIBUTES: frozenset[str] = frozenset(
|
|
17
|
+
{
|
|
18
|
+
"mro",
|
|
19
|
+
*UNSAFE_FUNCTION_ATTRIBUTES,
|
|
20
|
+
*UNSAFE_METHOD_ATTRIBUTES,
|
|
21
|
+
*UNSAFE_GENERATOR_ATTRIBUTES,
|
|
22
|
+
*UNSAFE_COROUTINE_ATTRIBUTES,
|
|
23
|
+
*UNSAFE_ASYNC_GENERATOR_ATTRIBUTES,
|
|
24
|
+
}
|
|
25
|
+
)
|
|
5
26
|
|
|
6
27
|
|
|
7
28
|
@cache
|
|
@@ -16,3 +37,20 @@ def sandboxed_template(source: str, *, lstrip_blocks: bool = False) -> Template:
|
|
|
16
37
|
sandbox rejects raises ``jinja2.exceptions.SecurityError``.
|
|
17
38
|
"""
|
|
18
39
|
return _sandboxed_environment(lstrip_blocks=lstrip_blocks).from_string(source)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def validate_sandboxed_template(source: str, *, lstrip_blocks: bool = False) -> str:
|
|
43
|
+
"""Validate that ``source`` compiles and accesses no sandbox-forbidden attributes.
|
|
44
|
+
|
|
45
|
+
Raises ``jinja2.TemplateSyntaxError`` on malformed syntax (and top-level
|
|
46
|
+
unknown filters/tests; filters inside conditionals are resolved by Jinja at
|
|
47
|
+
render time) and ``jinja2.exceptions.SecurityError`` on static dot-access to
|
|
48
|
+
private or internal Python attributes.
|
|
49
|
+
"""
|
|
50
|
+
env = _sandboxed_environment(lstrip_blocks=lstrip_blocks)
|
|
51
|
+
ast = env.parse(source)
|
|
52
|
+
for node in ast.find_all(nodes.Getattr):
|
|
53
|
+
if node.attr.startswith("_") or node.attr in _UNSAFE_STATIC_ATTRIBUTES:
|
|
54
|
+
raise SecurityError("access to private or internal attribute is unsafe.")
|
|
55
|
+
env.from_string(source)
|
|
56
|
+
return source
|
|
@@ -17,6 +17,7 @@ from unique_toolkit.agentic.tools.tool_progress_reporter import ToolProgressRepo
|
|
|
17
17
|
from unique_toolkit.app.schemas import ChatEvent, McpServer, McpTool
|
|
18
18
|
from unique_toolkit.chat.schemas import MessageLog, MessageLogStatus
|
|
19
19
|
from unique_toolkit.chat.service import ChatService
|
|
20
|
+
from unique_toolkit.content.constants import ASSISTANT_GENERATED_METADATA_KEY
|
|
20
21
|
from unique_toolkit.content.functions import upload_content_from_bytes
|
|
21
22
|
from unique_toolkit.content.schemas import ContentChunk, ContentReference
|
|
22
23
|
from unique_toolkit.language_model import LanguageModelService
|
|
@@ -370,6 +371,7 @@ class MCPToolWrapper(Tool[MCPToolConfig]):
|
|
|
370
371
|
chat_id=self._event.payload.chat_id,
|
|
371
372
|
skip_ingestion=True,
|
|
372
373
|
hide_in_chat=True,
|
|
374
|
+
metadata={ASSISTANT_GENERATED_METADATA_KEY: True},
|
|
373
375
|
)
|
|
374
376
|
content_id = content.id
|
|
375
377
|
except Exception as e:
|
|
@@ -18,6 +18,7 @@ from unique_toolkit.agentic.tools.openai_builtin.code_interpreter.postprocessors
|
|
|
18
18
|
from unique_toolkit.agentic.tools.openai_builtin.code_interpreter.schemas import (
|
|
19
19
|
CodeInterpreterContainerFile,
|
|
20
20
|
)
|
|
21
|
+
from unique_toolkit.content.constants import ASSISTANT_GENERATED_METADATA_KEY
|
|
21
22
|
from unique_toolkit.content.schemas import Content
|
|
22
23
|
from unique_toolkit.log_redaction import redact_filename
|
|
23
24
|
|
|
@@ -71,7 +72,8 @@ def _artifact_metadata(
|
|
|
71
72
|
container_id=file.container_id,
|
|
72
73
|
file_id=file.file_id,
|
|
73
74
|
filepath=f"/mnt/data/{file.filename}",
|
|
74
|
-
).model_dump()
|
|
75
|
+
).model_dump(),
|
|
76
|
+
ASSISTANT_GENERATED_METADATA_KEY: True,
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
|
{unique_toolkit-2026.46.0.dev9.dist-info → unique_toolkit-2026.46.0.dev11.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: unique-toolkit
|
|
3
|
-
Version: 2026.46.0.
|
|
3
|
+
Version: 2026.46.0.dev11
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Cedric Klinkert, Martin Fadler, Sadique Sheik, Fabian Schläpfer, Pascal Hauri, Ejiroghene Oki-Peter, Rami Azouz, Ricardo Visini, Sanzio Monti
|
|
6
6
|
Author-email: Cedric Klinkert <cedric.klinkert@unique.ch>, Martin Fadler <martin.fadler@unique.ch>, Sadique Sheik <sadique@unique.ch>, Fabian Schläpfer <fabian@unique.ch>, Pascal Hauri <pascal@unique.ch>, Ejiroghene Oki-Peter <oki-peter.ejiroghene@unique.ai>, Rami Azouz <rami.ext@unique.ch>, Ricardo Visini <ricardo.visini@unique.ch>, Sanzio Monti <sanzio.monti@unique.ai>
|
|
@@ -75,7 +75,7 @@ unique_toolkit/_common/utils/files.py,sha256=cPJU3Y5DlAbdakPaF1vICOCOujMHESrP4b3
|
|
|
75
75
|
unique_toolkit/_common/utils/image/encode.py,sha256=IJhtTcIT_azhiDsPp15oYs2LPze2l-sGlZrJASHrDVI,658
|
|
76
76
|
unique_toolkit/_common/utils/jinja/helpers.py,sha256=UQWj0hFMtnuUFYDJ8NKbEblvYE8DrWX1o7fKQU3H9IQ,262
|
|
77
77
|
unique_toolkit/_common/utils/jinja/render.py,sha256=D48hVbDcaGz_O01Xgawd3fBgbFIiZkThShZyjN96nBo,537
|
|
78
|
-
unique_toolkit/_common/utils/jinja/sandbox.py,sha256=
|
|
78
|
+
unique_toolkit/_common/utils/jinja/sandbox.py,sha256=b39fvrHyvFiTK1ft8mIlPOvaiP7JktLLpzLgPK27hbA,2045
|
|
79
79
|
unique_toolkit/_common/utils/jinja/schema.py,sha256=uyGGN1uvcGTBBujs8KUrnMMND73MNC5YGJkSETVyUCo,2007
|
|
80
80
|
unique_toolkit/_common/utils/jinja/utils.py,sha256=0SrwN6qfLlRJrl38HG7qsMr5-DwpABNnM9LpqpMgwUA,2814
|
|
81
81
|
unique_toolkit/_common/utils/structured_output/__init__.py,sha256=nm_orZrlCXL0FPLUg0Jv6Ty1flXPkCgZ9caAWaS8rz8,38
|
|
@@ -209,7 +209,7 @@ unique_toolkit/agentic/tools/factory.py,sha256=YK9uh2EqotQFb9stsXs-A8lsNaxklTCd_
|
|
|
209
209
|
unique_toolkit/agentic/tools/mcp/__init__.py,sha256=RLF_p-LDRC7GhiB3fdCi4u3bh6V9PY_w26fg61BLyco,122
|
|
210
210
|
unique_toolkit/agentic/tools/mcp/manager.py,sha256=EfWbfNhB8Lnx2EqBgUXhK7klFLaBv2eezvYq8J0TXyo,3808
|
|
211
211
|
unique_toolkit/agentic/tools/mcp/models.py,sha256=DaBVzwJ4dqtgzm8Mv0-NOGBU04zyVe-RgWntBhkpmnE,742
|
|
212
|
-
unique_toolkit/agentic/tools/mcp/tool_wrapper.py,sha256=
|
|
212
|
+
unique_toolkit/agentic/tools/mcp/tool_wrapper.py,sha256=gP8UYYKQQ13KYc5i6VL7pBiWf28RhVeCQxCfWaOMpVQ,15936
|
|
213
213
|
unique_toolkit/agentic/tools/names.py,sha256=MDF0ONLrxeC-iz--EtyrHAox_RN6zasxo5MSbXQYGyw,412
|
|
214
214
|
unique_toolkit/agentic/tools/openai_builtin/__init__.py,sha256=Q6d9mhsLRVF3erT2yMxLld62D3FTZ8nbovI4vLv4Nso,701
|
|
215
215
|
unique_toolkit/agentic/tools/openai_builtin/base.py,sha256=QWF-GL_fkJqzGPpxvtg69-TB_IjsrxokeJVQESzH-18,1415
|
|
@@ -224,7 +224,7 @@ unique_toolkit/agentic/tools/openai_builtin/code_interpreter/builder/_memory.py,
|
|
|
224
224
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/builder/builder.py,sha256=QFvfJT7PE6XIf1mftURptTevOmYBp5Ln_eIsro5O7s8,6546
|
|
225
225
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/config.py,sha256=C4Vrj_xLgLB8AEUz-cp0JpXAIwYwz-VaSRh-xAG7PW8,2381
|
|
226
226
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/__init__.py,sha256=SzEiUqxIw8D4_51SvTt-8oTOYTGirYkmH4J6SgojzME,634
|
|
227
|
-
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/artifacts.py,sha256=
|
|
227
|
+
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/artifacts.py,sha256=Y2Nja1TcLHoFsAZfdG0iGprcNN6co_6PVx7XQKdN1RQ,7110
|
|
228
228
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/code_display.py,sha256=Q1XI_Wi2Lg8Vn31nGTtu6YHOyz9QBFwI6d9MBYGhkW8,3425
|
|
229
229
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/generated_files.py,sha256=Gz-s9YT0fSQTX5axsDjr8F1ByViiPlhBhwdA4ynWtro,67828
|
|
230
230
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/office_preview.py,sha256=2-u9NlNRyQ7PC5b6vW_5CypzVbfNUWRd9DAbCSKE4qk,5099
|
|
@@ -276,7 +276,7 @@ unique_toolkit/chat/service.py,sha256=6D00OL4QrGafbOhTaC5zNXaNgg7gS5W_2ePVa4Lhqp
|
|
|
276
276
|
unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,1445
|
|
277
277
|
unique_toolkit/chat/utils.py,sha256=CsD9IER2gA1IOV0fmUOl-N0LmKvA7JP9dGrOqeOY0Gg,1173
|
|
278
278
|
unique_toolkit/content/__init__.py,sha256=yeVVqHjltRii_XwPOX2uId2kHF0_wCcSC4jwalv_5g8,1707
|
|
279
|
-
unique_toolkit/content/constants.py,sha256=
|
|
279
|
+
unique_toolkit/content/constants.py,sha256=GvyazpNv4M2UJFdsLIo7Z5dVSPERPTqslRAA8VgQw-M,235
|
|
280
280
|
unique_toolkit/content/functions.py,sha256=fLEueWbiMOOO43HxnltqdRR_Et9JoQCjnCm5WZA94DY,36284
|
|
281
281
|
unique_toolkit/content/schemas.py,sha256=sYkXvP7SItHbaVvnU8HKgBPgQdJemPk3fgonDOvROpQ,12955
|
|
282
282
|
unique_toolkit/content/service.py,sha256=mZZtIm23dK6ZXI66V98dbYMwMvIjdKuhc-EnKnPczzI,31591
|
|
@@ -434,6 +434,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
|
|
|
434
434
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
435
435
|
unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
|
|
436
436
|
unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
|
|
437
|
-
unique_toolkit-2026.46.0.
|
|
438
|
-
unique_toolkit-2026.46.0.
|
|
439
|
-
unique_toolkit-2026.46.0.
|
|
437
|
+
unique_toolkit-2026.46.0.dev11.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
438
|
+
unique_toolkit-2026.46.0.dev11.dist-info/METADATA,sha256=HIuu2kOfD6q6FUhYSy7hDrVWWyPM5-Wa0m9V4yBwXm0,7822
|
|
439
|
+
unique_toolkit-2026.46.0.dev11.dist-info/RECORD,,
|
|
File without changes
|