@gpzhang2001/sharpkit-ui 0.2.1
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/LICENSE +201 -0
- package/README.md +20 -0
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/lib/client.js +202 -0
- package/lib/client.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/package.json +54 -0
- package/src/client/PentestRows.tsx +88 -0
- package/src/client/index.ts +32 -0
- package/src/client/locales.ts +17 -0
- package/src/index.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 gpzhang2001
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @gpzhang2001/sharpkit-ui
|
|
2
|
+
|
|
3
|
+
Web UI 卡片:keyed toolview 富卡 + pentest locale 字典。唯一需要构建产物的包(浏览器加载,exports["./client"] = lib/client.js + `dsh.client` 声明)。
|
|
4
|
+
|
|
5
|
+
## 卡片(tool.call.toolview,按 wire 工具名 keyed)
|
|
6
|
+
|
|
7
|
+
- **exec_command** → 终端卡:`sh/pty` 前缀 + 命令行 + 输出滚动区(monospace)
|
|
8
|
+
- **view_image** → 截图卡:路径 + "image attached to the result" 提示
|
|
9
|
+
- **create_vulnerability_report / create_dependency_report** → 发现卡:severity 色标(critical→info 五档)+ 标题 + report_id
|
|
10
|
+
|
|
11
|
+
客户端纪律:卡片只从 slot 传入的持久 call slice 派生(禁 I/O/时钟/随机/会话读取);payload 解析失败回退为空——回放安全由构造保证。locale 走 typed 字典(zh 键集 + en 完整对账)。
|
|
12
|
+
|
|
13
|
+
## 构建与验证
|
|
14
|
+
|
|
15
|
+
- `pnpm bundle`(tsdown,平台模块表 external + `window.__ModuleLoader__` handoff)
|
|
16
|
+
- 已验证:`dsh web --patch <mount>` 启动后,index 启动图含 `@gpzhang2001/sharpkit-ui/client.js`;按图请求精确 combo 返回 200 且包含本包注册字节
|
|
17
|
+
|
|
18
|
+
## 会话节点(ConversationNode)
|
|
19
|
+
|
|
20
|
+
findings 流 / agent 图谱 / 进度业务卡属 ConversationNode 层,将在后续版本提供。
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This project builds on and derives assets from the following upstream
|
|
4
|
+
projects. Their licenses and attribution requirements are acknowledged here
|
|
5
|
+
as required by Apache-2.0 §4.
|
|
6
|
+
|
|
7
|
+
## strix — https://github.com/usestrix/strix
|
|
8
|
+
|
|
9
|
+
Copyright 2025 OmniSecure Inc. Licensed under the Apache License, Version 2.0.
|
|
10
|
+
|
|
11
|
+
sharpkit is an independent TypeScript reimplementation of strix's pentest
|
|
12
|
+
domain assets on the DeepSeek Harness plugin architecture (no strix code is
|
|
13
|
+
executed; no Python runtime is required). The following files are carried
|
|
14
|
+
**verbatim or near-verbatim** from strix and remain subject to the above
|
|
15
|
+
notice:
|
|
16
|
+
|
|
17
|
+
| sharpkit path | Origin | Changes |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `packages/preset/src/system_prompt.jinja` | `strix/agents/prompts/system_prompt.jinja` | none (byte-identical template) |
|
|
20
|
+
| `packages/skills/skills/**` (75 knowledge packs, 11 categories) | `strix/strix/skills/**` | none (migrated verbatim) |
|
|
21
|
+
| `sandbox-image/caido_api.py` | `strix/strix/tools/proxy/caido_api.py` | none (byte-identical) |
|
|
22
|
+
| `sandbox-image/docker-entrypoint.sh` | `strix/containers/docker-entrypoint.sh` | none (byte-identical) |
|
|
23
|
+
| `sandbox-image/Dockerfile` | `strix/containers/Dockerfile` | COPY source paths adapted to the standalone context; added overridable `GOPROXY`/`KALI_MIRROR` build args |
|
|
24
|
+
| `packages/preset/src/skills.ts` | `strix/strix/skills/__init__.py` | reimplemented in TypeScript (selection/validation semantics) |
|
|
25
|
+
|
|
26
|
+
The following subsystems are **semantic ports** (behavior-preserving
|
|
27
|
+
reimplementation, no verbatim text): the SARIF writer and vulnerability
|
|
28
|
+
artifact writers (`packages/tool-reporting/src/{sarif,writers,state}.ts` ←
|
|
29
|
+
`strix/report/*`), the reporting/analysis tool schemas
|
|
30
|
+
(`packages/tool-reporting`, `packages/tool-analysis` ← `strix/tools/*`), the
|
|
31
|
+
Caido client (`packages/tool-proxy/src/client.ts` ← the client half of
|
|
32
|
+
`strix/tools/proxy/caido_api.py`), the sandbox session manager
|
|
33
|
+
(`packages/sandbox` ← `strix/runtime/*`), and the scan-mode preset semantics
|
|
34
|
+
(`packages/preset` ← `strix/agents/factory.py` + `core/inputs.py`).
|
|
35
|
+
|
|
36
|
+
## DeepSeek Harness (dsh) — https://github.com/deepseek-ai/deepseek-harness
|
|
37
|
+
|
|
38
|
+
MIT License. Copyright (c) DeepSeek.
|
|
39
|
+
|
|
40
|
+
dsh is a runtime dependency only (`@deepseek-ai/dsh-*` npm packages); no dsh
|
|
41
|
+
source is embedded or modified in this repository.
|
|
42
|
+
|
|
43
|
+
## Sandbox image components
|
|
44
|
+
|
|
45
|
+
The built `sharpkit-sandbox` image bundles Kali Linux and third-party security
|
|
46
|
+
tools (nmap, sqlmap, nuclei, Caido, agent-browser, chromium, and others), each
|
|
47
|
+
under its own license inside the image. Distributing a built image is the
|
|
48
|
+
operator's responsibility; this repository ships only the build recipe.
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@gpzhang2001/sharpkit-ui",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/client/PentestRows.tsx
|
|
9
|
+
/** Best-effort JSON parse for durable call payloads. */
|
|
10
|
+
function parsePayload(raw) {
|
|
11
|
+
if (typeof raw !== "string") return {};
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(raw);
|
|
14
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
15
|
+
} catch {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Extract the newest text content from a result payload array. */
|
|
20
|
+
function lastText(value) {
|
|
21
|
+
if (Array.isArray(value)) for (let index = value.length - 1; index >= 0; index--) {
|
|
22
|
+
const item = value[index];
|
|
23
|
+
if (typeof item === "object" && item !== null && item["text"] !== void 0) return String(item["text"]);
|
|
24
|
+
}
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
/** Terminal-style card for exec_command. */
|
|
28
|
+
function ExecRow(props) {
|
|
29
|
+
const payload = parsePayload(props.call?.arguments);
|
|
30
|
+
const cmd = String(payload["cmd"] ?? "");
|
|
31
|
+
const output = lastText(props.result?.content);
|
|
32
|
+
const isTTY = payload["tty"] === true;
|
|
33
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
34
|
+
style: {
|
|
35
|
+
fontFamily: "monospace",
|
|
36
|
+
fontSize: "0.86em",
|
|
37
|
+
borderLeft: "3px solid #58b7ff",
|
|
38
|
+
background: "rgba(88,183,255,0.06)",
|
|
39
|
+
borderRadius: 4,
|
|
40
|
+
overflow: "hidden"
|
|
41
|
+
},
|
|
42
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
43
|
+
style: {
|
|
44
|
+
padding: "4px 8px",
|
|
45
|
+
opacity: .85
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
49
|
+
style: { color: "#58b7ff" },
|
|
50
|
+
children: isTTY ? "pty" : "sh"
|
|
51
|
+
}),
|
|
52
|
+
" $ ",
|
|
53
|
+
cmd
|
|
54
|
+
]
|
|
55
|
+
}), output !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
56
|
+
style: {
|
|
57
|
+
margin: 0,
|
|
58
|
+
padding: "4px 8px",
|
|
59
|
+
borderTop: "1px solid rgba(128,128,128,0.25)",
|
|
60
|
+
whiteSpace: "pre-wrap",
|
|
61
|
+
maxHeight: 320,
|
|
62
|
+
overflowY: "auto"
|
|
63
|
+
},
|
|
64
|
+
children: output
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Severity-colored card for create_vulnerability_report / dependency findings. */
|
|
69
|
+
const SEVERITY_COLORS = {
|
|
70
|
+
critical: "#e5534b",
|
|
71
|
+
high: "#e5863b",
|
|
72
|
+
medium: "#d4a72c",
|
|
73
|
+
low: "#57ab5a",
|
|
74
|
+
info: "#539bf5"
|
|
75
|
+
};
|
|
76
|
+
function FindingRow(props) {
|
|
77
|
+
const payload = parsePayload(props.result?.meta ?? props.result?.content);
|
|
78
|
+
const severity = String(payload["severity"] ?? "info").toLowerCase();
|
|
79
|
+
const color = SEVERITY_COLORS[severity] ?? "#539bf5";
|
|
80
|
+
const title = String(payload["title"] ?? payload["message"] ?? "finding");
|
|
81
|
+
const reportId = String(payload["report_id"] ?? "");
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
83
|
+
style: {
|
|
84
|
+
borderLeft: `3px solid ${color}`,
|
|
85
|
+
padding: "4px 8px",
|
|
86
|
+
borderRadius: 4
|
|
87
|
+
},
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
90
|
+
style: {
|
|
91
|
+
color,
|
|
92
|
+
fontWeight: 600,
|
|
93
|
+
textTransform: "uppercase",
|
|
94
|
+
fontSize: "0.8em"
|
|
95
|
+
},
|
|
96
|
+
children: severity
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
99
|
+
style: { marginLeft: 8 },
|
|
100
|
+
children: title
|
|
101
|
+
}),
|
|
102
|
+
reportId !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
103
|
+
style: {
|
|
104
|
+
marginLeft: 8,
|
|
105
|
+
opacity: .5,
|
|
106
|
+
fontSize: "0.85em"
|
|
107
|
+
},
|
|
108
|
+
children: reportId
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** Screenshot card for view_image. */
|
|
114
|
+
function ViewImageRow(props) {
|
|
115
|
+
const payload = parsePayload(props.call?.arguments);
|
|
116
|
+
const path = String(payload["path"] ?? "");
|
|
117
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
118
|
+
style: {
|
|
119
|
+
borderLeft: "3px solid #8a7ff0",
|
|
120
|
+
padding: "4px 8px",
|
|
121
|
+
borderRadius: 4,
|
|
122
|
+
fontFamily: "monospace",
|
|
123
|
+
fontSize: "0.86em"
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
127
|
+
style: { color: "#8a7ff0" },
|
|
128
|
+
children: "screenshot"
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
131
|
+
style: {
|
|
132
|
+
marginLeft: 8,
|
|
133
|
+
opacity: .75
|
|
134
|
+
},
|
|
135
|
+
children: path
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
138
|
+
style: {
|
|
139
|
+
marginLeft: 8,
|
|
140
|
+
opacity: .4,
|
|
141
|
+
fontSize: "0.85em"
|
|
142
|
+
},
|
|
143
|
+
children: "image attached to the result"
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/client/locales.ts
|
|
150
|
+
/** `pentest` namespace dictionaries (key-set source of truth: zh). */
|
|
151
|
+
const NS = "pentest";
|
|
152
|
+
const zh = {
|
|
153
|
+
"exec.label": "沙箱命令",
|
|
154
|
+
"finding.label": "漏洞发现",
|
|
155
|
+
"screenshot.label": "截图"
|
|
156
|
+
};
|
|
157
|
+
const en = {
|
|
158
|
+
"exec.label": "Sandbox command",
|
|
159
|
+
"finding.label": "Finding",
|
|
160
|
+
"screenshot.label": "Screenshot"
|
|
161
|
+
};
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/client/index.ts
|
|
164
|
+
/** Required client services: the slot registry and the locale registry. */
|
|
165
|
+
const inject = ["slots", "locale"];
|
|
166
|
+
/** Client plugin body: register dictionaries and the keyed tool rows. */
|
|
167
|
+
function apply(ctx) {
|
|
168
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
169
|
+
zh,
|
|
170
|
+
en
|
|
171
|
+
}), "pentest-ui: dictionaries");
|
|
172
|
+
ctx.slots.inject("tool.call.toolview", () => {
|
|
173
|
+
ctx.slots.register({
|
|
174
|
+
name: "tool.call.toolview",
|
|
175
|
+
key: "exec_command",
|
|
176
|
+
locale: NS
|
|
177
|
+
}, ExecRow);
|
|
178
|
+
ctx.slots.register({
|
|
179
|
+
name: "tool.call.toolview",
|
|
180
|
+
key: "view_image",
|
|
181
|
+
locale: NS
|
|
182
|
+
}, ViewImageRow);
|
|
183
|
+
ctx.slots.register({
|
|
184
|
+
name: "tool.call.toolview",
|
|
185
|
+
key: "create_vulnerability_report",
|
|
186
|
+
locale: NS
|
|
187
|
+
}, FindingRow);
|
|
188
|
+
ctx.slots.register({
|
|
189
|
+
name: "tool.call.toolview",
|
|
190
|
+
key: "create_dependency_report",
|
|
191
|
+
locale: NS
|
|
192
|
+
}, FindingRow);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
exports.apply = apply;
|
|
197
|
+
exports.inject = inject;
|
|
198
|
+
return module.exports;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/client/PentestRows.tsx","../src/client/locales.ts","../src/client/index.ts"],"sourcesContent":["/**\n * Pentest toolview cards, browser half (M5): presenter-derived, replay-safe\n * rows keyed by wire tool name. Each card renders only from the durable\n * call slice the slot owner passes — no I/O, no clock, no session reads\n * (client discipline); malformed payloads fall back to the generic text.\n */\nimport type { ToolCallViewProps } from '@deepseek-ai/dsh-client-ui-tool/client'\n\n/** Best-effort JSON parse for durable call payloads. */\nfunction parsePayload(raw: unknown): Record<string, unknown> {\n if (typeof raw !== 'string') return {}\n try {\n const parsed = JSON.parse(raw) as unknown\n return typeof parsed === 'object' && parsed !== null ? parsed as Record<string, unknown> : {}\n } catch {\n return {}\n }\n}\n\n/** Extract the newest text content from a result payload array. */\nfunction lastText(value: unknown): string {\n if (Array.isArray(value)) {\n for (let index = value.length - 1; index >= 0; index--) {\n const item = value[index]\n if (typeof item === 'object' && item !== null && (item as Record<string, unknown>)['text'] !== undefined) {\n return String((item as Record<string, unknown>)['text'])\n }\n }\n }\n return ''\n}\n\n/** Terminal-style card for exec_command. */\nexport function ExecRow(props: ToolCallViewProps) {\n const payload = parsePayload(props.call?.arguments)\n const cmd = String(payload['cmd'] ?? '')\n const output = lastText(props.result?.content)\n const isTTY = payload['tty'] === true\n return (\n <div style={{ fontFamily: 'monospace', fontSize: '0.86em', borderLeft: '3px solid #58b7ff', background: 'rgba(88,183,255,0.06)', borderRadius: 4, overflow: 'hidden' }}>\n <div style={{ padding: '4px 8px', opacity: 0.85 }}>\n <span style={{ color: '#58b7ff' }}>{isTTY ? 'pty' : 'sh'}</span>\n {' $ '}\n {cmd}\n </div>\n {output !== '' && (\n <pre style={{ margin: 0, padding: '4px 8px', borderTop: '1px solid rgba(128,128,128,0.25)', whiteSpace: 'pre-wrap', maxHeight: 320, overflowY: 'auto' }}>{output}</pre>\n )}\n </div>\n )\n}\n\n/** Severity-colored card for create_vulnerability_report / dependency findings. */\nconst SEVERITY_COLORS: Record<string, string> = {\n critical: '#e5534b',\n high: '#e5863b',\n medium: '#d4a72c',\n low: '#57ab5a',\n info: '#539bf5',\n}\n\nexport function FindingRow(props: ToolCallViewProps) {\n const payload = parsePayload(props.result?.meta ?? props.result?.content)\n const severity = String(payload['severity'] ?? 'info').toLowerCase()\n const color = SEVERITY_COLORS[severity] ?? '#539bf5'\n const title = String(payload['title'] ?? payload['message'] ?? 'finding')\n const reportId = String(payload['report_id'] ?? '')\n return (\n <div style={{ borderLeft: `3px solid ${color}`, padding: '4px 8px', borderRadius: 4 }}>\n <span style={{ color, fontWeight: 600, textTransform: 'uppercase', fontSize: '0.8em' }}>{severity}</span>\n <span style={{ marginLeft: 8 }}>{title}</span>\n {reportId !== '' && <span style={{ marginLeft: 8, opacity: 0.5, fontSize: '0.85em' }}>{reportId}</span>}\n </div>\n )\n}\n\n/** Screenshot card for view_image. */\nexport function ViewImageRow(props: ToolCallViewProps) {\n const payload = parsePayload(props.call?.arguments)\n const path = String(payload['path'] ?? '')\n return (\n <div style={{ borderLeft: '3px solid #8a7ff0', padding: '4px 8px', borderRadius: 4, fontFamily: 'monospace', fontSize: '0.86em' }}>\n <span style={{ color: '#8a7ff0' }}>screenshot</span>\n <span style={{ marginLeft: 8, opacity: 0.75 }}>{path}</span>\n <span style={{ marginLeft: 8, opacity: 0.4, fontSize: '0.85em' }}>image attached to the result</span>\n </div>\n )\n}\n","/** `pentest` namespace dictionaries (key-set source of truth: zh). */\n\nexport const NS = 'pentest'\n\nexport const zh = {\n 'exec.label': '沙箱命令',\n 'finding.label': '漏洞发现',\n 'screenshot.label': '截图',\n} satisfies Record<string, string>\n\nexport type PentestKey = keyof typeof zh\n\nexport const en = {\n 'exec.label': 'Sandbox command',\n 'finding.label': 'Finding',\n 'screenshot.label': 'Screenshot',\n} satisfies Record<PentestKey, string>\n","/**\n * Pentest UI, browser half (M5): keyed toolview cards for the wire tools\n * (exec_command, view_image, create_vulnerability_report,\n * create_dependency_report) plus the pentest locale dictionaries. Pure\n * derivation from durable call slices — replay-safe by construction.\n */\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-renderer/client'\nimport { ExecRow, FindingRow, ViewImageRow } from './PentestRows.tsx'\nimport { en, NS, zh, type PentestKey } from './locales.ts'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** The pentest toolview copy. */\n pentest: PentestKey\n }\n}\n\n/** Required client services: the slot registry and the locale registry. */\nexport const inject = ['slots', 'locale']\n\n/** Client plugin body: register dictionaries and the keyed tool rows. */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'pentest-ui: dictionaries')\n ctx.slots.inject('tool.call.toolview', () => {\n ctx.slots.register({ name: 'tool.call.toolview', key: 'exec_command', locale: NS }, ExecRow)\n ctx.slots.register({ name: 'tool.call.toolview', key: 'view_image', locale: NS }, ViewImageRow)\n ctx.slots.register({ name: 'tool.call.toolview', key: 'create_vulnerability_report', locale: NS }, FindingRow)\n ctx.slots.register({ name: 'tool.call.toolview', key: 'create_dependency_report', locale: NS }, FindingRow)\n })\n}\n"],"mappings":"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"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.ts","names":[],"sources":["../src/index.d.ts"],"sourcesContent":["/**\n * Pentest UI package, node half: the client half ships built artifacts via\n * exports[\"./client\"] and the dsh.client declaration; no host behavior.\n * @module @gpzhang2001/sharpkit-ui\n */\n/** No host-side behavior. */\nexport declare function apply(): void;\n"],"mappings":";AAAA,IAAW,CAAC,SAAS;CAAC;OAAS,CAAC;CAAG,CAAC;AAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pentest UI package, node half: the client half ships built artifacts via
|
|
4
|
+
* exports["./client"] and the dsh.client declaration; no host behavior.
|
|
5
|
+
* @module @gpzhang2001/sharpkit-ui
|
|
6
|
+
*/
|
|
7
|
+
/** No host-side behavior. */
|
|
8
|
+
function apply() {}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { apply };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Pentest UI package, node half: the client half ships built artifacts via\n * exports[\"./client\"] and the dsh.client declaration; no host behavior.\n * @module @gpzhang2001/sharpkit-ui\n */\n\n/** No host-side behavior. */\nexport function apply(): void {}\n"],"mappings":";;;;;;;AAOA,SAAgB,QAAc,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gpzhang2001/sharpkit-ui",
|
|
3
|
+
"description": "Pentest Web UI cards: keyed toolviews for exec/screenshots/findings + pentest locale dictionaries",
|
|
4
|
+
"version": "0.2.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/gpzhang2001/sharpkit.git",
|
|
11
|
+
"directory": "packages/ui"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"default": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./src/*": "./src/*",
|
|
21
|
+
"./client": "./lib/client.js",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"lib",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"THIRD_PARTY_NOTICES.md"
|
|
29
|
+
],
|
|
30
|
+
"dsh": {
|
|
31
|
+
"client": {
|
|
32
|
+
"inject": [
|
|
33
|
+
"@deepseek-ai/dsh-client-locale",
|
|
34
|
+
"@deepseek-ai/dsh-client-ui-renderer"
|
|
35
|
+
],
|
|
36
|
+
"platform": "web"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
41
|
+
"@deepseek-ai/dsh-client-locale": "0.1.2-rc.1",
|
|
42
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.1.2-rc.1",
|
|
43
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.2-rc.1",
|
|
44
|
+
"@deepseek-ai/dsh-client-ui-tool": "0.1.2-rc.1",
|
|
45
|
+
"@types/react": "~18.3.1",
|
|
46
|
+
"react": "^18.2.0",
|
|
47
|
+
"tsdown": "^0.22.2"
|
|
48
|
+
},
|
|
49
|
+
"main": "lib/index.js",
|
|
50
|
+
"types": "lib/index.d.ts",
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "cp ../../LICENSE ../../THIRD_PARTY_NOTICES.md . && tsdown && mv -f lib/index.ts lib/index.d.ts && mv -f lib/index.ts.map lib/index.d.ts.map"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pentest toolview cards, browser half (M5): presenter-derived, replay-safe
|
|
3
|
+
* rows keyed by wire tool name. Each card renders only from the durable
|
|
4
|
+
* call slice the slot owner passes — no I/O, no clock, no session reads
|
|
5
|
+
* (client discipline); malformed payloads fall back to the generic text.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolCallViewProps } from '@deepseek-ai/dsh-client-ui-tool/client'
|
|
8
|
+
|
|
9
|
+
/** Best-effort JSON parse for durable call payloads. */
|
|
10
|
+
function parsePayload(raw: unknown): Record<string, unknown> {
|
|
11
|
+
if (typeof raw !== 'string') return {}
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(raw) as unknown
|
|
14
|
+
return typeof parsed === 'object' && parsed !== null ? parsed as Record<string, unknown> : {}
|
|
15
|
+
} catch {
|
|
16
|
+
return {}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Extract the newest text content from a result payload array. */
|
|
21
|
+
function lastText(value: unknown): string {
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
for (let index = value.length - 1; index >= 0; index--) {
|
|
24
|
+
const item = value[index]
|
|
25
|
+
if (typeof item === 'object' && item !== null && (item as Record<string, unknown>)['text'] !== undefined) {
|
|
26
|
+
return String((item as Record<string, unknown>)['text'])
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return ''
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Terminal-style card for exec_command. */
|
|
34
|
+
export function ExecRow(props: ToolCallViewProps) {
|
|
35
|
+
const payload = parsePayload(props.call?.arguments)
|
|
36
|
+
const cmd = String(payload['cmd'] ?? '')
|
|
37
|
+
const output = lastText(props.result?.content)
|
|
38
|
+
const isTTY = payload['tty'] === true
|
|
39
|
+
return (
|
|
40
|
+
<div style={{ fontFamily: 'monospace', fontSize: '0.86em', borderLeft: '3px solid #58b7ff', background: 'rgba(88,183,255,0.06)', borderRadius: 4, overflow: 'hidden' }}>
|
|
41
|
+
<div style={{ padding: '4px 8px', opacity: 0.85 }}>
|
|
42
|
+
<span style={{ color: '#58b7ff' }}>{isTTY ? 'pty' : 'sh'}</span>
|
|
43
|
+
{' $ '}
|
|
44
|
+
{cmd}
|
|
45
|
+
</div>
|
|
46
|
+
{output !== '' && (
|
|
47
|
+
<pre style={{ margin: 0, padding: '4px 8px', borderTop: '1px solid rgba(128,128,128,0.25)', whiteSpace: 'pre-wrap', maxHeight: 320, overflowY: 'auto' }}>{output}</pre>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Severity-colored card for create_vulnerability_report / dependency findings. */
|
|
54
|
+
const SEVERITY_COLORS: Record<string, string> = {
|
|
55
|
+
critical: '#e5534b',
|
|
56
|
+
high: '#e5863b',
|
|
57
|
+
medium: '#d4a72c',
|
|
58
|
+
low: '#57ab5a',
|
|
59
|
+
info: '#539bf5',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function FindingRow(props: ToolCallViewProps) {
|
|
63
|
+
const payload = parsePayload(props.result?.meta ?? props.result?.content)
|
|
64
|
+
const severity = String(payload['severity'] ?? 'info').toLowerCase()
|
|
65
|
+
const color = SEVERITY_COLORS[severity] ?? '#539bf5'
|
|
66
|
+
const title = String(payload['title'] ?? payload['message'] ?? 'finding')
|
|
67
|
+
const reportId = String(payload['report_id'] ?? '')
|
|
68
|
+
return (
|
|
69
|
+
<div style={{ borderLeft: `3px solid ${color}`, padding: '4px 8px', borderRadius: 4 }}>
|
|
70
|
+
<span style={{ color, fontWeight: 600, textTransform: 'uppercase', fontSize: '0.8em' }}>{severity}</span>
|
|
71
|
+
<span style={{ marginLeft: 8 }}>{title}</span>
|
|
72
|
+
{reportId !== '' && <span style={{ marginLeft: 8, opacity: 0.5, fontSize: '0.85em' }}>{reportId}</span>}
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Screenshot card for view_image. */
|
|
78
|
+
export function ViewImageRow(props: ToolCallViewProps) {
|
|
79
|
+
const payload = parsePayload(props.call?.arguments)
|
|
80
|
+
const path = String(payload['path'] ?? '')
|
|
81
|
+
return (
|
|
82
|
+
<div style={{ borderLeft: '3px solid #8a7ff0', padding: '4px 8px', borderRadius: 4, fontFamily: 'monospace', fontSize: '0.86em' }}>
|
|
83
|
+
<span style={{ color: '#8a7ff0' }}>screenshot</span>
|
|
84
|
+
<span style={{ marginLeft: 8, opacity: 0.75 }}>{path}</span>
|
|
85
|
+
<span style={{ marginLeft: 8, opacity: 0.4, fontSize: '0.85em' }}>image attached to the result</span>
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pentest UI, browser half (M5): keyed toolview cards for the wire tools
|
|
3
|
+
* (exec_command, view_image, create_vulnerability_report,
|
|
4
|
+
* create_dependency_report) plus the pentest locale dictionaries. Pure
|
|
5
|
+
* derivation from durable call slices — replay-safe by construction.
|
|
6
|
+
*/
|
|
7
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
8
|
+
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
9
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
10
|
+
import { ExecRow, FindingRow, ViewImageRow } from './PentestRows.tsx'
|
|
11
|
+
import { en, NS, zh, type PentestKey } from './locales.ts'
|
|
12
|
+
|
|
13
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
14
|
+
interface LocaleNamespaceMap {
|
|
15
|
+
/** The pentest toolview copy. */
|
|
16
|
+
pentest: PentestKey
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Required client services: the slot registry and the locale registry. */
|
|
21
|
+
export const inject = ['slots', 'locale']
|
|
22
|
+
|
|
23
|
+
/** Client plugin body: register dictionaries and the keyed tool rows. */
|
|
24
|
+
export function apply(ctx: ClientContext): void {
|
|
25
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'pentest-ui: dictionaries')
|
|
26
|
+
ctx.slots.inject('tool.call.toolview', () => {
|
|
27
|
+
ctx.slots.register({ name: 'tool.call.toolview', key: 'exec_command', locale: NS }, ExecRow)
|
|
28
|
+
ctx.slots.register({ name: 'tool.call.toolview', key: 'view_image', locale: NS }, ViewImageRow)
|
|
29
|
+
ctx.slots.register({ name: 'tool.call.toolview', key: 'create_vulnerability_report', locale: NS }, FindingRow)
|
|
30
|
+
ctx.slots.register({ name: 'tool.call.toolview', key: 'create_dependency_report', locale: NS }, FindingRow)
|
|
31
|
+
})
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** `pentest` namespace dictionaries (key-set source of truth: zh). */
|
|
2
|
+
|
|
3
|
+
export const NS = 'pentest'
|
|
4
|
+
|
|
5
|
+
export const zh = {
|
|
6
|
+
'exec.label': '沙箱命令',
|
|
7
|
+
'finding.label': '漏洞发现',
|
|
8
|
+
'screenshot.label': '截图',
|
|
9
|
+
} satisfies Record<string, string>
|
|
10
|
+
|
|
11
|
+
export type PentestKey = keyof typeof zh
|
|
12
|
+
|
|
13
|
+
export const en = {
|
|
14
|
+
'exec.label': 'Sandbox command',
|
|
15
|
+
'finding.label': 'Finding',
|
|
16
|
+
'screenshot.label': 'Screenshot',
|
|
17
|
+
} satisfies Record<PentestKey, string>
|
package/src/index.ts
ADDED