@jidekaixin2dian/dsh-toolgate 0.0.0-stage → 0.1.5
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/CHANGELOG.md +71 -0
- package/LICENSE +21 -0
- package/README.en.md +71 -0
- package/README.md +73 -3
- package/README.zh.md +6 -0
- package/SECURITY.md +16 -0
- package/assets/readme-schema-v2.svg +18 -0
- package/cordis.patch.yml +6 -0
- package/icon.svg +10 -0
- package/lib/api-payload.js +10 -0
- package/lib/audit.js +25 -0
- package/lib/client.js +516 -0
- package/lib/config-files.js +73 -0
- package/lib/groups.js +59 -0
- package/lib/host-paths.js +39 -0
- package/lib/index.js +501 -0
- package/lib/mcp-config.js +239 -0
- package/lib/skills-config.js +86 -0
- package/lib/skills-runtime.js +139 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +103 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.5 — 2026-10-28
|
|
4
|
+
|
|
5
|
+
- 发布与更新维护:明确 npm 安装、GitHub 来源迁移、市场检测与重启步骤;保留既有运行时行为。
|
|
6
|
+
- 固定并验证 DSH 0.2.1-rc.4,同时保留较旧宿主回归。
|
|
7
|
+
- 新增 npm 公开发布配置、tag/main/CI/归档门槛与 Trusted Publishing 工作流;继续复用宿主运行时,不安装第二份 DSH。
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 0.1.4 — 2026-10-26
|
|
11
|
+
|
|
12
|
+
- 重整中英文 README:安装更新优先,保留兼容与权限边界,开发说明移入独立文档。
|
|
13
|
+
- Refresh Chinese/English documentation and installation guidance; runtime behavior is unchanged.
|
|
14
|
+
- 使用 GitHub 源安装以支持市场版本检查;包含尚未发包的 rc.2 / rc.3 宿主支持声明。
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Previously unreleased compatibility metadata
|
|
18
|
+
|
|
19
|
+
- Declare the supported host explicitly: `engines.dsh >=0.2.1-rc.2`, with CI
|
|
20
|
+
continuously verifying both 0.2.1-rc.2 and 0.2.1-rc.3.
|
|
21
|
+
- Re-pin the host regression suite to DSH 0.2.1-rc.3 (`1f81c047`): rc.2 → rc.3
|
|
22
|
+
changed no source in the packages this plugin uses, and the authenticated host
|
|
23
|
+
suite passes unchanged (11 passed / 1 browser-gated skip). Shipped plugin
|
|
24
|
+
code and the peer range (`>=0.2.1-rc.1 <0.3.0-0`) are unchanged.
|
|
25
|
+
|
|
26
|
+
## 0.1.3 — 2026-10-24
|
|
27
|
+
|
|
28
|
+
- Add an append-only audit log at `DSH_HOME/toolgate-audit.jsonl`: one JSON line
|
|
29
|
+
per management write (op, target id, outcome, timestamp), never containing
|
|
30
|
+
env/header values. It rotates past 1 MiB to `.1` and a failed append never
|
|
31
|
+
blocks the operation it records.
|
|
32
|
+
- Tighten the management API: `mcp-add` and `mcp-edit` now accept only the
|
|
33
|
+
documented `{ row }` payload; flattened probe bodies are rejected with the
|
|
34
|
+
normal validation error instead of being silently interpreted.
|
|
35
|
+
- Add the `allowSessionOverride` plugin config (default `true`). Set it to `false`
|
|
36
|
+
to make the `toolgate` model tool read-only: `action=session` and `action=reset`
|
|
37
|
+
return a notice without changing tool visibility, so prompt-injected turns
|
|
38
|
+
cannot hide tool groups; the authenticated settings page still owns the gate.
|
|
39
|
+
- Cap configuration backups at the 20 most recent copies under
|
|
40
|
+
`DSH_HOME/backups/toolgate/`; pruning runs after a successful write only, so
|
|
41
|
+
failed writes keep their recovery copy. Backup directories are matched by the
|
|
42
|
+
exact `timestamp-uuid` naming pattern and foreign entries are never removed.
|
|
43
|
+
|
|
44
|
+
## 0.1.2 — 2026-10-23
|
|
45
|
+
|
|
46
|
+
- Align the release tag and archive, including the scoped client bundle. The
|
|
47
|
+
0.1.1 archive had the fix, but its tag source did not; neither is overwritten.
|
|
48
|
+
- Verify published package versions and all archive files against tagged source,
|
|
49
|
+
allowing only Git checkout line endings, and check the GitHub asset digest.
|
|
50
|
+
- Correct stale installation/version documentation and remove the stale UI
|
|
51
|
+
version label.
|
|
52
|
+
|
|
53
|
+
## 0.1.1 — 2026-10-23
|
|
54
|
+
|
|
55
|
+
- Authenticate management requests using the running host Connection service;
|
|
56
|
+
reject missing auth support and omit secret values from management responses.
|
|
57
|
+
- Edit YAML nodes precisely, retain sibling configuration and complex arguments,
|
|
58
|
+
compose profile/global/overlay layers using the host, and back up atomic writes.
|
|
59
|
+
- Resolve the current DSH home/profile and selected workspace from host services.
|
|
60
|
+
Keep Skill provider/path identities, scoped restrictions and recoverable trash.
|
|
61
|
+
- Own state per plugin instance, release restrictions on unload and clear disposed
|
|
62
|
+
Agent overrides. Roll back Skill toggles if settings cannot be persisted; use
|
|
63
|
+
unique private temporary files and clean failed writes.
|
|
64
|
+
- Add Windows/Linux unit, authenticated host/browser and archive-install CI.
|
|
65
|
+
|
|
66
|
+
See [root-cause evidence](docs/root-cause-fixes.md). Release 0.1.0 lacks these fixes. Its historical assets remain unchanged.
|
|
67
|
+
|
|
68
|
+
## 0.1.0
|
|
69
|
+
|
|
70
|
+
Initial Toolgate release after the Context Budget rename. Historical archive;
|
|
71
|
+
does not include the authentication, configuration integrity or lifecycle fixes.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jidekaixin2dian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Toolgate
|
|
2
|
+
|
|
3
|
+
**Bring only the tools you need into the next prompt.**
|
|
4
|
+
|
|
5
|
+
[中文](README.md) · [Marketplace](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-toolgate/) · [Download](https://github.com/jidekaixin2dian/dsh-toolgate/releases/latest) · [Changelog](CHANGELOG.md)
|
|
6
|
+
|
|
7
|
+
Manage MCP servers, skills and tool visibility in one DSH settings page. Hide schemas by server and restore them when needed; MCP processes keep running.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
| Tab | What it does |
|
|
12
|
+
|---|---|
|
|
13
|
+
| Budget | Estimate context usage, hide groups / all MCP / the largest group, restore tools |
|
|
14
|
+
| MCP servers | Add, edit, enable, disable and remove stdio or streamable-http servers |
|
|
15
|
+
| Skills | Search, create and toggle by Session workspace; move eligible local skills to trash |
|
|
16
|
+
|
|
17
|
+
## Install and update
|
|
18
|
+
|
|
19
|
+
Requires **DSH >=0.2.1-rc.2 and Node >=24**. CI verifies DSH rc.2 / rc.3 / rc.4.
|
|
20
|
+
|
|
21
|
+
Search for **dsh-toolgate**, author **jidekaixin2dian**, in the marketplace. Both npm and GitHub sources support version checks. Once the catalog recognizes the npm package it prefers npm; existing users can check under installed plugins. Catalog mappings may take time to refresh.
|
|
22
|
+
|
|
23
|
+
Alternatively, quit DSH and run the same command to install or update, then reopen it:
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
dsh plugin --profile desktop add @jidekaixin2dian/dsh-toolgate --registry=https://registry.npmjs.org
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Offline packages are available in [Releases](https://github.com/jidekaixin2dian/dsh-toolgate/releases/latest). While Desktop owns a running profile, use its plugin manager and respect profile locks.
|
|
30
|
+
|
|
31
|
+
## Get started
|
|
32
|
+
|
|
33
|
+
1. Open **Settings → Toolgate** and review groups under Budget.
|
|
34
|
+
2. Hide groups this task does not need. Changes apply from the next prompt and can be reversed.
|
|
35
|
+
3. Before changing MCP or skills, verify the configuration scope or selected workspace Session.
|
|
36
|
+
|
|
37
|
+
MCP edits preserve unrelated configuration and comments, back up before writing and reject ambiguous or read-only sources. Secret fields are retained by default and never returned in plaintext. Audit entries exclude secret values.
|
|
38
|
+
|
|
39
|
+
Skills retain source identity. Only matching local `.dsh/skills/<name>` directories can move to `.trash`; shared, bundled, custom and virtual sources stay read-only.
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary>Session tool and fixed global settings</summary>
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
toolgate action=status
|
|
46
|
+
toolgate action=session disabled=["mcp:github", "skills"]
|
|
47
|
+
toolgate action=reset
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`mcp` matches all MCP; `mcp:<server>` matches one. Settings apply globally to sessions and subagents, while Session overrides affect only that Session.
|
|
51
|
+
|
|
52
|
+
Set `allowSessionOverride: false` to prevent the model from changing or resetting Session overrides. The settings page still controls the global gate.
|
|
53
|
+
|
|
54
|
+
</details>
|
|
55
|
+
|
|
56
|
+
Existing `.tgz` or local installations can use the same command in the same profile to switch to npm; GitHub installs remain updatable.
|
|
57
|
+
|
|
58
|
+
## Boundaries
|
|
59
|
+
|
|
60
|
+
- Hiding tools is context budgeting, **not a permission sandbox**. MCP processes keep running; permitted Session overrides can restore tools.
|
|
61
|
+
- Token estimates use schema / description length. Neither estimates nor illustrated counts establish cost or latency savings.
|
|
62
|
+
- Some dynamically scoped tools cannot be hidden; use their manager to unload them. Skill ZIP / folder import is not implemented.
|
|
63
|
+
- MCP management writes configuration. Review changes to hand-edited files. Backups under `DSH_HOME/backups/toolgate/` retain the latest 20 after successful writes and **may contain original secrets; keep them private**.
|
|
64
|
+
- Audit records are stored in `DSH_HOME/toolgate-audit.jsonl`. Management requires host authentication and the current profile, failing closed if either is missing.
|
|
65
|
+
- Plugin updates require an app restart; existing MCP configuration changes can hot reload through the host.
|
|
66
|
+
|
|
67
|
+
To remove, quit DSH, run `dsh plugin --profile desktop remove @jidekaixin2dian/dsh-toolgate`, then reopen it.
|
|
68
|
+
|
|
69
|
+
[Development and verification](https://github.com/jidekaixin2dian/dsh-toolgate/blob/main/docs/development.md) · [Security](SECURITY.md) · [Issues](https://github.com/jidekaixin2dian/dsh-toolgate/issues)
|
|
70
|
+
|
|
71
|
+
MIT · Independent community plugin, not affiliated with DeepSeek.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Toolgate · 工具闸门
|
|
2
|
+
|
|
3
|
+
**让下一轮 prompt 只带需要的工具。**
|
|
4
|
+
|
|
5
|
+
[English](README.en.md) · [插件市场](https://awesome-dsh-plugin.com/p/jidekaixin2dian/dsh-toolgate/) · [下载](https://github.com/jidekaixin2dian/dsh-toolgate/releases/latest) · [更新记录](CHANGELOG.md)
|
|
6
|
+
|
|
7
|
+
在 DSH 的一个设置页里管理 MCP 服务器、Skill 和工具可见性。按服务器隐藏整组工具 schema,需要时再恢复,MCP 进程继续运行。
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
| 页面 | 你可以做什么 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| 预算 | 查看估算占用,隐藏单组、全部 MCP 或最大组,恢复工具 |
|
|
14
|
+
| MCP 服务器 | 新增、编辑、启停、删除服务器;支持 stdio 与 streamable-http |
|
|
15
|
+
| Skills | 按会话工作区搜索、新建、启停;可删除的本地 Skill 移到回收目录 |
|
|
16
|
+
|
|
17
|
+
## 安装与更新
|
|
18
|
+
|
|
19
|
+
需要 **DSH >=0.2.1-rc.2、Node >=24**;持续验证 DSH rc.2 / rc.3 / rc.4。
|
|
20
|
+
|
|
21
|
+
在插件市场搜索 **dsh-toolgate**,确认作者为 **jidekaixin2dian**。npm 与 GitHub 来源都支持版本检查;市场识别 npm 包后优先使用 npm,可在「已安装」中检查更新。目录映射可能稍后刷新。
|
|
22
|
+
|
|
23
|
+
也可完全退出 DSH 后执行以下命令;再次执行即可更新,随后重新打开 DSH:
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
dsh plugin --profile desktop add @jidekaixin2dian/dsh-toolgate --registry=https://registry.npmjs.org
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
离线安装包见 [Release](https://github.com/jidekaixin2dian/dsh-toolgate/releases/latest)。桌面端运行期间请使用其插件管理器,遵守 profile 锁。
|
|
30
|
+
|
|
31
|
+
## 三步开始
|
|
32
|
+
|
|
33
|
+
1. 打开 **设置 → 工具闸门**,在「预算」查看各组工具。
|
|
34
|
+
2. 隐藏当前任务不需要的组;从下一轮 prompt 生效,可随时恢复。
|
|
35
|
+
3. 管理 MCP 或 Skill 时,先核对配置范围或选中的工作区会话,再保存。
|
|
36
|
+
|
|
37
|
+
MCP 编辑保留无关配置和注释,写前备份;歧义配置或只读来源会拒绝修改。密钥字段默认保留,不回传明文。操作审计记录不包含密钥值。
|
|
38
|
+
|
|
39
|
+
Skill 保留来源身份,仅匹配当前根目录的本地 `.dsh/skills/<name>` 可删除,删除移入 `.trash`。共享、bundled、custom 与虚拟来源保持只读。
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary>会话工具与固定全局设置</summary>
|
|
43
|
+
|
|
44
|
+
模型可使用以下工具查看状态或设置当前会话的覆盖:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
toolgate action=status
|
|
48
|
+
toolgate action=session disabled=["mcp:github", "skills"]
|
|
49
|
+
toolgate action=reset
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`mcp` 匹配全部 MCP;`mcp:<server>` 只匹配一台服务器。设置页预算作用于所有会话和子代理,会话覆盖只影响当前会话。
|
|
53
|
+
|
|
54
|
+
设置 `allowSessionOverride: false` 后,模型不能更改或重置会话覆盖;全局设置仍由设置页控制。
|
|
55
|
+
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
旧 `.tgz` 或本地安装用户可在同一 profile 执行上面的命令切换到 npm;已有 GitHub 源仍可更新。
|
|
59
|
+
|
|
60
|
+
## 使用边界
|
|
61
|
+
|
|
62
|
+
- 工具隐藏用于上下文预算,**不是权限沙箱**。MCP 进程不会因此停止;默认允许的会话覆盖可以恢复工具。
|
|
63
|
+
- token 数与示意图都不代表实际费用或速度收益;token 仅按 schema / 描述长度估算。
|
|
64
|
+
- agent 作用域中的部分动态工具无法隐藏,请用对应管理器卸载。Skill ZIP / 文件夹导入尚未实现。
|
|
65
|
+
- MCP 管理会写配置;手工编辑过配置时先核对差异。备份位于 `DSH_HOME/backups/toolgate/`,成功写入后保留最近 20 份,**备份可能包含原始密钥,请勿公开**。
|
|
66
|
+
- 审计记录位于 `DSH_HOME/toolgate-audit.jsonl`。管理接口依赖宿主认证和当前 profile,缺失时拒绝访问。
|
|
67
|
+
- 插件本身更新需要重开 DSH;已有 MCP 配置变更可由宿主热重载。
|
|
68
|
+
|
|
69
|
+
卸载:退出 DSH 后执行 `dsh plugin --profile desktop remove @jidekaixin2dian/dsh-toolgate`,再重新打开。
|
|
70
|
+
|
|
71
|
+
[开发与验证](https://github.com/jidekaixin2dian/dsh-toolgate/blob/main/docs/development.md) · [安全说明](SECURITY.md) · [反馈问题](https://github.com/jidekaixin2dian/dsh-toolgate/issues)
|
|
72
|
+
|
|
73
|
+
MIT · 独立社区插件,与 DeepSeek 官方无隶属关系。
|
package/README.zh.md
ADDED
package/SECURITY.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
Management HTTP requests use the running DSH Connection service's authentication and Host/Origin checks. Missing authentication support closes the endpoint. This requires a host exposing `connection.requestRejection()`; the integration suite pins DSH 0.2.1-rc.2. A public plugin header is an additional request marker, never a credential.
|
|
4
|
+
|
|
5
|
+
MCP environment and header values are not returned in management responses. Leave their replacement controls unchecked to retain existing values. Configuration edits preserve unrelated nodes and create recoverable copies under `DSH_HOME/backups/toolgate/` before writing. These backups contain original configuration, including secrets; keep them private. After a successful write only the 20 most recent backup copies are retained; failed writes keep their recovery copy. Every management write also appends one JSON line (operation, target, outcome, timestamp — never secret values) to `DSH_HOME/toolgate-audit.jsonl`, rotated past 1 MiB.
|
|
6
|
+
|
|
7
|
+
Only selected local `.dsh/skills/<name>/SKILL.md` directory bundles can be moved to `.trash`. Shared `.agents`, bundled, custom and virtual provider sources remain read-only. Directory links cannot redirect deletion or trash outside the selected root.
|
|
8
|
+
|
|
9
|
+
Tool hiding controls context exposure, not a security sandbox or a process boundary. Session overrides can restore groups, scoped tools may remain visible, and MCP processes continue running. The plugin config option `allowSessionOverride: false` makes the model tool read-only (status only) so prompt-injected turns cannot reconfigure tool visibility; the authenticated settings page still owns the global gate.
|
|
10
|
+
|
|
11
|
+
For security reports use GitHub private vulnerability reporting when available. Do not put real credentials, cookies, launch URLs, configuration backups or private conversation contents in public issues or PRs.
|
|
12
|
+
|
|
13
|
+
Release 0.1.1's uploaded archive contains the scoped client startup fix, but its
|
|
14
|
+
Git tag predates that change. Use 0.1.2 or later for matching source and archive.
|
|
15
|
+
Release integrity checks reject version drift, missing files and differences
|
|
16
|
+
between archive content and tagged source (apart from checkout line endings).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 360" role="img" aria-label="工具 schema 数量示意:从 267 个降到 60 个">
|
|
2
|
+
<rect width="1200" height="360" fill="#f3f4ed"/>
|
|
3
|
+
|
|
4
|
+
<text x="60" y="150" fill="#151515" font-family="Noto Serif SC, Source Han Serif SC, Songti SC, SimSun, serif" font-size="100" font-weight="700">267</text>
|
|
5
|
+
<text x="60" y="190" fill="#6f6f66" font-family="Noto Sans SC, Microsoft YaHei, sans-serif" font-size="18">个工具进入 prompt</text>
|
|
6
|
+
|
|
7
|
+
<path d="M470 135h180" stroke="#151515" stroke-width="2"/>
|
|
8
|
+
<path d="M650 135l-12-7M650 135l-12 7" stroke="#151515" stroke-width="2" fill="none"/>
|
|
9
|
+
<text x="476" y="116" fill="#151515" font-family="Noto Sans SC, Microsoft YaHei, sans-serif" font-size="17">隐藏整组</text>
|
|
10
|
+
|
|
11
|
+
<text x="720" y="150" fill="#151515" font-family="Noto Serif SC, Source Han Serif SC, Songti SC, SimSun, serif" font-size="100" font-weight="700">60</text>
|
|
12
|
+
<text x="720" y="190" fill="#6f6f66" font-family="Noto Sans SC, Microsoft YaHei, sans-serif" font-size="18">个工具进入 prompt</text>
|
|
13
|
+
|
|
14
|
+
<rect x="60" y="250" width="600" height="18" fill="#151515" opacity=".14"/>
|
|
15
|
+
<rect x="60" y="290" width="135" height="18" fill="#c8f663"/>
|
|
16
|
+
|
|
17
|
+
<text x="60" y="340" fill="#6f6f66" font-family="Noto Sans SC, Microsoft YaHei, sans-serif" font-size="14">一个例子。实际数量取决于已安装的 MCP 服务器和 Skill。</text>
|
|
18
|
+
</svg>
|
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" role="img" aria-label="dsh-toolgate">
|
|
2
|
+
<rect width="128" height="128" rx="24" fill="#0f172a"/>
|
|
3
|
+
<rect x="24" y="72" width="14" height="32" rx="3" fill="#38bdf8"/>
|
|
4
|
+
<rect x="46" y="52" width="14" height="52" rx="3" fill="#38bdf8"/>
|
|
5
|
+
<rect x="68" y="34" width="14" height="70" rx="3" fill="#a78bfa"/>
|
|
6
|
+
<rect x="90" y="60" width="14" height="44" rx="3" fill="#38bdf8"/>
|
|
7
|
+
<path d="M22 30h48" stroke="#e2e8f0" stroke-width="5" stroke-linecap="round"/>
|
|
8
|
+
<path d="M60 30l-9-7M60 30l-9 7" stroke="#e2e8f0" stroke-width="4" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
9
|
+
</svg>
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The settings page posts `{ op, args }` (see `api()` in client.js), while the
|
|
2
|
+
// route handlers read operation fields directly. Accept both shapes so the
|
|
3
|
+
// bundle and the host cannot drift apart again — and so a hand-written probe
|
|
4
|
+
// or a future client that flattens the body still lands on the same fields.
|
|
5
|
+
export function requestArgs(payload) {
|
|
6
|
+
if (!payload || typeof payload !== 'object') return {}
|
|
7
|
+
const args = payload.args
|
|
8
|
+
return args && typeof args === 'object' && !Array.isArray(args) ? args : payload
|
|
9
|
+
}
|
|
10
|
+
|
package/lib/audit.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Append-only operation log next to the plugin state file: one JSON line per
|
|
2
|
+
// management write with what changed, when, and whether it succeeded. Values
|
|
3
|
+
// of env/headers are never recorded; a failed append must not break the
|
|
4
|
+
// operation it describes.
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
|
|
8
|
+
const MAX_BYTES = 1024 * 1024
|
|
9
|
+
|
|
10
|
+
export function appendAudit(home, entry) {
|
|
11
|
+
const file = path.join(home, 'toolgate-audit.jsonl')
|
|
12
|
+
try {
|
|
13
|
+
try {
|
|
14
|
+
if (fs.statSync(file).size > MAX_BYTES) {
|
|
15
|
+
try { fs.unlinkSync(file + '.1') } catch { /* first rotation */ }
|
|
16
|
+
fs.renameSync(file, file + '.1')
|
|
17
|
+
}
|
|
18
|
+
} catch { /* size check on a missing file */ }
|
|
19
|
+
fs.appendFileSync(file, JSON.stringify({ at: new Date().toISOString(), ...entry }) + '\n',
|
|
20
|
+
{ encoding: 'utf8', mode: 0o600 })
|
|
21
|
+
return true
|
|
22
|
+
} catch {
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
}
|