tweek 0.2.0__py3-none-any.whl → 0.3.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.
- tweek/__init__.py +1 -1
- tweek/cli.py +769 -457
- tweek/cli_helpers.py +6 -6
- tweek/cli_model.py +7 -7
- tweek/config/manager.py +1 -1
- tweek/diagnostics.py +59 -7
- tweek/hooks/pre_tool_use.py +3 -3
- tweek/mcp/approval_cli.py +4 -4
- tweek/sandbox/linux.py +5 -5
- tweek/skill_template/SKILL.md +2 -3
- tweek/skill_template/cli-reference.md +33 -18
- tweek/skill_template/scripts/check_installed.py +4 -4
- {tweek-0.2.0.dist-info → tweek-0.3.0.dist-info}/METADATA +20 -14
- {tweek-0.2.0.dist-info → tweek-0.3.0.dist-info}/RECORD +20 -18
- tweek-0.3.0.dist-info/licenses/NOTICE +199 -0
- tweek-0.3.0.dist-info/top_level.txt +2 -0
- tweek-openclaw-plugin/node_modules/flatted/python/flatted.py +149 -0
- tweek-0.2.0.dist-info/top_level.txt +0 -1
- {tweek-0.2.0.dist-info → tweek-0.3.0.dist-info}/WHEEL +0 -0
- {tweek-0.2.0.dist-info → tweek-0.3.0.dist-info}/entry_points.txt +0 -0
- {tweek-0.2.0.dist-info → tweek-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Tweek
|
|
2
|
+
Copyright 2025 Tommy Mancino / Tweek, LLC
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Tweek, LLC.
|
|
5
|
+
|
|
6
|
+
=========================================================================
|
|
7
|
+
|
|
8
|
+
Third-Party Components
|
|
9
|
+
=========================================================================
|
|
10
|
+
|
|
11
|
+
This project uses the following third-party components. Their licenses
|
|
12
|
+
and copyright notices are reproduced below, as required by their
|
|
13
|
+
respective licenses.
|
|
14
|
+
|
|
15
|
+
-------------------------------------------------------------------------
|
|
16
|
+
ProtectAI DeBERTa-v3-base Prompt Injection v2
|
|
17
|
+
-------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
Source: https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2
|
|
20
|
+
License: Apache License 2.0
|
|
21
|
+
Copyright (c) 2024 Protect AI, Inc.
|
|
22
|
+
|
|
23
|
+
A fine-tuned DeBERTa-v3-base model for binary prompt injection
|
|
24
|
+
classification. Used by Tweek as an on-device classifier for detecting
|
|
25
|
+
prompt injection attacks. The model is downloaded at user request via
|
|
26
|
+
`tweek model download` and stored locally at ~/.tweek/models/.
|
|
27
|
+
|
|
28
|
+
Tweek does not modify or redistribute the model weights. The model is
|
|
29
|
+
downloaded directly from HuggingFace by the end user.
|
|
30
|
+
|
|
31
|
+
Citation:
|
|
32
|
+
@misc{deberta-v3-base-prompt-injection-v2,
|
|
33
|
+
author = {ProtectAI.com},
|
|
34
|
+
title = {Fine-Tuned DeBERTa-v3-base for Prompt Injection Detection},
|
|
35
|
+
year = {2024},
|
|
36
|
+
publisher = {HuggingFace},
|
|
37
|
+
url = {https://huggingface.co/protectai/deberta-v3-base-prompt-injection-v2},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
41
|
+
you may not use this file except in compliance with the License.
|
|
42
|
+
You may obtain a copy of the License at
|
|
43
|
+
|
|
44
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
45
|
+
|
|
46
|
+
Unless required by applicable law or agreed to in writing, software
|
|
47
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
49
|
+
See the License for the specific language governing permissions and
|
|
50
|
+
limitations under the License.
|
|
51
|
+
|
|
52
|
+
-------------------------------------------------------------------------
|
|
53
|
+
Microsoft DeBERTa-v3-base (upstream base model)
|
|
54
|
+
-------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
Source: https://huggingface.co/microsoft/deberta-v3-base
|
|
57
|
+
License: MIT License
|
|
58
|
+
Copyright (c) Microsoft Corporation.
|
|
59
|
+
|
|
60
|
+
The ProtectAI prompt injection model above is fine-tuned from
|
|
61
|
+
Microsoft's DeBERTa-v3-base pre-trained language model.
|
|
62
|
+
|
|
63
|
+
Citation:
|
|
64
|
+
@misc{he2021debertav3,
|
|
65
|
+
title = {DeBERTaV3: Improving DeBERTa using ELECTRA-Style
|
|
66
|
+
Pre-Training with Gradient-Disentangled Embedding Sharing},
|
|
67
|
+
author = {Pengcheng He and Jianfeng Gao and Weizhu Chen},
|
|
68
|
+
year = {2021},
|
|
69
|
+
eprint = {2111.09543},
|
|
70
|
+
archivePrefix = {arXiv},
|
|
71
|
+
primaryClass = {cs.CL},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
75
|
+
a copy of this software and associated documentation files (the
|
|
76
|
+
"Software"), to deal in the Software without restriction, including
|
|
77
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
78
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
79
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
80
|
+
the following conditions:
|
|
81
|
+
|
|
82
|
+
The above copyright notice and this permission notice shall be
|
|
83
|
+
included in all copies or substantial portions of the Software.
|
|
84
|
+
|
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
88
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
89
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
90
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
91
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
92
|
+
|
|
93
|
+
-------------------------------------------------------------------------
|
|
94
|
+
ONNX Runtime
|
|
95
|
+
-------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
Source: https://github.com/microsoft/onnxruntime
|
|
98
|
+
License: MIT License
|
|
99
|
+
Copyright (c) Microsoft Corporation.
|
|
100
|
+
|
|
101
|
+
Used as the inference engine for the local prompt injection classifier.
|
|
102
|
+
Installed as an optional dependency via `pip install tweek[local-models]`.
|
|
103
|
+
|
|
104
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
105
|
+
a copy of this software and associated documentation files (the
|
|
106
|
+
"Software"), to deal in the Software without restriction, including
|
|
107
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
108
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
109
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
110
|
+
the following conditions:
|
|
111
|
+
|
|
112
|
+
The above copyright notice and this permission notice shall be
|
|
113
|
+
included in all copies or substantial portions of the Software.
|
|
114
|
+
|
|
115
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
116
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
117
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
118
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
119
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
120
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
121
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
122
|
+
|
|
123
|
+
-------------------------------------------------------------------------
|
|
124
|
+
HuggingFace Tokenizers
|
|
125
|
+
-------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
Source: https://github.com/huggingface/tokenizers
|
|
128
|
+
License: Apache License 2.0
|
|
129
|
+
Copyright (c) 2019 HuggingFace Inc.
|
|
130
|
+
|
|
131
|
+
Used for tokenizing input text before feeding to the local ONNX model.
|
|
132
|
+
Installed as an optional dependency via `pip install tweek[local-models]`.
|
|
133
|
+
|
|
134
|
+
Licensed under the Apache License, Version 2.0.
|
|
135
|
+
|
|
136
|
+
-------------------------------------------------------------------------
|
|
137
|
+
NumPy
|
|
138
|
+
-------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
Source: https://github.com/numpy/numpy
|
|
141
|
+
License: BSD 3-Clause License
|
|
142
|
+
Copyright (c) 2005-2024, NumPy Developers.
|
|
143
|
+
|
|
144
|
+
Used for numerical operations in the local model inference pipeline
|
|
145
|
+
(softmax scoring, tensor manipulation). Installed as an optional
|
|
146
|
+
dependency via `pip install tweek[local-models]`.
|
|
147
|
+
|
|
148
|
+
Redistribution and use in source and binary forms, with or without
|
|
149
|
+
modification, are permitted provided that the following conditions are
|
|
150
|
+
met:
|
|
151
|
+
|
|
152
|
+
1. Redistributions of source code must retain the above copyright
|
|
153
|
+
notice, this list of conditions and the following disclaimer.
|
|
154
|
+
|
|
155
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
156
|
+
notice, this list of conditions and the following disclaimer in
|
|
157
|
+
the documentation and/or other materials provided with the
|
|
158
|
+
distribution.
|
|
159
|
+
|
|
160
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
161
|
+
contributors may be used to endorse or promote products derived
|
|
162
|
+
from this software without specific prior written permission.
|
|
163
|
+
|
|
164
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
165
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
166
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
167
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
168
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
169
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
170
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
171
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
172
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
173
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
174
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
175
|
+
|
|
176
|
+
=========================================================================
|
|
177
|
+
|
|
178
|
+
Runtime Dependencies
|
|
179
|
+
=========================================================================
|
|
180
|
+
|
|
181
|
+
The following packages are installed via pip as runtime dependencies.
|
|
182
|
+
They are NOT bundled or vendored — each carries its own license in its
|
|
183
|
+
distribution. Listed here for transparency.
|
|
184
|
+
|
|
185
|
+
click >=8.0 BSD-3-Clause Pallets Projects
|
|
186
|
+
pyyaml >=6.0 MIT Kirill Simonov / YAML community
|
|
187
|
+
rich >=13.0 MIT Will McGugan
|
|
188
|
+
keyring >=25.0 MIT Jason R. Coombs
|
|
189
|
+
|
|
190
|
+
Optional dependencies (installed only when the user requests them):
|
|
191
|
+
|
|
192
|
+
anthropic >=0.18.0 MIT Anthropic, PBC
|
|
193
|
+
openai >=1.0.0 MIT OpenAI
|
|
194
|
+
google-generativeai Apache-2.0 Google LLC
|
|
195
|
+
mcp >=1.0.0 MIT Anthropic, PBC
|
|
196
|
+
mitmproxy >=10.0 MIT mitmproxy contributors
|
|
197
|
+
secretstorage >=3.0 BSD-3-Clause Dmitry Shachnev
|
|
198
|
+
|
|
199
|
+
=========================================================================
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# ISC License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2018-2025, Andrea Giammarchi, @WebReflection
|
|
4
|
+
#
|
|
5
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
# purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
# copyright notice and this permission notice appear in all copies.
|
|
8
|
+
#
|
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
14
|
+
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
# PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
import json as _json
|
|
18
|
+
|
|
19
|
+
class _Known:
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.key = []
|
|
22
|
+
self.value = []
|
|
23
|
+
|
|
24
|
+
class _String:
|
|
25
|
+
def __init__(self, value):
|
|
26
|
+
self.value = value
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _array_keys(value):
|
|
30
|
+
keys = []
|
|
31
|
+
i = 0
|
|
32
|
+
for _ in value:
|
|
33
|
+
keys.append(i)
|
|
34
|
+
i += 1
|
|
35
|
+
return keys
|
|
36
|
+
|
|
37
|
+
def _object_keys(value):
|
|
38
|
+
keys = []
|
|
39
|
+
for key in value:
|
|
40
|
+
keys.append(key)
|
|
41
|
+
return keys
|
|
42
|
+
|
|
43
|
+
def _is_array(value):
|
|
44
|
+
return isinstance(value, (list, tuple))
|
|
45
|
+
|
|
46
|
+
def _is_object(value):
|
|
47
|
+
return isinstance(value, dict)
|
|
48
|
+
|
|
49
|
+
def _is_string(value):
|
|
50
|
+
return isinstance(value, str)
|
|
51
|
+
|
|
52
|
+
def _index(known, input, value):
|
|
53
|
+
input.append(value)
|
|
54
|
+
index = str(len(input) - 1)
|
|
55
|
+
known.key.append(value)
|
|
56
|
+
known.value.append(index)
|
|
57
|
+
return index
|
|
58
|
+
|
|
59
|
+
def _loop(keys, input, known, output):
|
|
60
|
+
for key in keys:
|
|
61
|
+
value = output[key]
|
|
62
|
+
if isinstance(value, _String):
|
|
63
|
+
_ref(key, input[int(value.value)], input, known, output)
|
|
64
|
+
|
|
65
|
+
return output
|
|
66
|
+
|
|
67
|
+
def _ref(key, value, input, known, output):
|
|
68
|
+
if _is_array(value) and value not in known:
|
|
69
|
+
known.append(value)
|
|
70
|
+
value = _loop(_array_keys(value), input, known, value)
|
|
71
|
+
elif _is_object(value) and value not in known:
|
|
72
|
+
known.append(value)
|
|
73
|
+
value = _loop(_object_keys(value), input, known, value)
|
|
74
|
+
|
|
75
|
+
output[key] = value
|
|
76
|
+
|
|
77
|
+
def _relate(known, input, value):
|
|
78
|
+
if _is_string(value) or _is_array(value) or _is_object(value):
|
|
79
|
+
try:
|
|
80
|
+
return known.value[known.key.index(value)]
|
|
81
|
+
except:
|
|
82
|
+
return _index(known, input, value)
|
|
83
|
+
|
|
84
|
+
return value
|
|
85
|
+
|
|
86
|
+
def _transform(known, input, value):
|
|
87
|
+
if _is_array(value):
|
|
88
|
+
output = []
|
|
89
|
+
for val in value:
|
|
90
|
+
output.append(_relate(known, input, val))
|
|
91
|
+
return output
|
|
92
|
+
|
|
93
|
+
if _is_object(value):
|
|
94
|
+
obj = {}
|
|
95
|
+
for key in value:
|
|
96
|
+
obj[key] = _relate(known, input, value[key])
|
|
97
|
+
return obj
|
|
98
|
+
|
|
99
|
+
return value
|
|
100
|
+
|
|
101
|
+
def _wrap(value):
|
|
102
|
+
if _is_string(value):
|
|
103
|
+
return _String(value)
|
|
104
|
+
|
|
105
|
+
if _is_array(value):
|
|
106
|
+
i = 0
|
|
107
|
+
for val in value:
|
|
108
|
+
value[i] = _wrap(val)
|
|
109
|
+
i += 1
|
|
110
|
+
|
|
111
|
+
elif _is_object(value):
|
|
112
|
+
for key in value:
|
|
113
|
+
value[key] = _wrap(value[key])
|
|
114
|
+
|
|
115
|
+
return value
|
|
116
|
+
|
|
117
|
+
def parse(value, *args, **kwargs):
|
|
118
|
+
json = _json.loads(value, *args, **kwargs)
|
|
119
|
+
wrapped = []
|
|
120
|
+
for value in json:
|
|
121
|
+
wrapped.append(_wrap(value))
|
|
122
|
+
|
|
123
|
+
input = []
|
|
124
|
+
for value in wrapped:
|
|
125
|
+
if isinstance(value, _String):
|
|
126
|
+
input.append(value.value)
|
|
127
|
+
else:
|
|
128
|
+
input.append(value)
|
|
129
|
+
|
|
130
|
+
value = input[0]
|
|
131
|
+
|
|
132
|
+
if _is_array(value):
|
|
133
|
+
return _loop(_array_keys(value), input, [value], value)
|
|
134
|
+
|
|
135
|
+
if _is_object(value):
|
|
136
|
+
return _loop(_object_keys(value), input, [value], value)
|
|
137
|
+
|
|
138
|
+
return value
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def stringify(value, *args, **kwargs):
|
|
142
|
+
known = _Known()
|
|
143
|
+
input = []
|
|
144
|
+
output = []
|
|
145
|
+
i = int(_index(known, input, value))
|
|
146
|
+
while i < len(input):
|
|
147
|
+
output.append(_transform(known, input, input[i]))
|
|
148
|
+
i += 1
|
|
149
|
+
return _json.dumps(output, *args, **kwargs)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
tweek
|
|
File without changes
|
|
File without changes
|
|
File without changes
|