@cveo/dsh-containers 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,225 @@
1
+ // packages/dsh-containers-ui/shared/constants.js
2
+ var NS = "dsh-containers";
3
+ var ROUTES = {
4
+ status: "/api/dsh-containers/status",
5
+ engineSelect: "/api/dsh-containers/engine/select",
6
+ containers: "/api/dsh-containers/containers",
7
+ action: "/api/dsh-containers/containers/action",
8
+ logs: "/api/dsh-containers/containers/logs",
9
+ stats: "/api/dsh-containers/containers/stats",
10
+ run: "/api/dsh-containers/containers/run",
11
+ images: "/api/dsh-containers/images",
12
+ imageAction: "/api/dsh-containers/images/action",
13
+ imageSearch: "/api/dsh-containers/images/search",
14
+ imageHubSearch: "/api/dsh-containers/images/hub-search",
15
+ imageTags: "/api/dsh-containers/images/tags",
16
+ imageInspect: "/api/dsh-containers/images/inspect",
17
+ pull: "/api/dsh-containers/images/pull",
18
+ df: "/api/dsh-containers/df",
19
+ volumes: "/api/dsh-containers/volumes",
20
+ volumeAction: "/api/dsh-containers/volumes/action",
21
+ networks: "/api/dsh-containers/networks",
22
+ networkAction: "/api/dsh-containers/networks/action",
23
+ /*
24
+ * 下面几条是 dsh-containers-extras 插件行注册的路由(客户端镜像声明)。
25
+ * dsh-containers-ui 是可选行、不能静态依赖 extras,所以路径在此重复一份;
26
+ * extras 被禁用时请求会 404,客户端按「能力未提供」优雅降级。
27
+ * 必须与 packages/dsh-containers-extras/src/host/extras.js 里的 ROUTES 保持同步。
28
+ */
29
+ k8s: "/api/dsh-containers/kiri/k8s",
30
+ machine: "/api/dsh-containers/kiri/machine",
31
+ setupKiri: "/api/dsh-containers/setup/kiri",
32
+ setupKiriStatus: "/api/dsh-containers/setup/kiri/status"
33
+ };
34
+
35
+ // packages/dsh-containers-ui/src/host/http.js
36
+ function sendJson(response, status, payload, request) {
37
+ const body = JSON.stringify(payload);
38
+ response.writeHead(status, {
39
+ "content-type": "application/json; charset=utf-8",
40
+ "cache-control": "no-store",
41
+ "content-length": Buffer.byteLength(body)
42
+ });
43
+ response.end(request?.method === "HEAD" ? void 0 : body);
44
+ }
45
+ async function readJsonBody(request) {
46
+ const chunks = [];
47
+ let size = 0;
48
+ for await (const chunk of request) {
49
+ size += chunk.length;
50
+ if (size > 65536) throw new Error("请求体过大");
51
+ chunks.push(chunk);
52
+ }
53
+ if (chunks.length === 0) return null;
54
+ const text = Buffer.concat(chunks).toString("utf8").trim();
55
+ if (!text) return null;
56
+ return JSON.parse(text);
57
+ }
58
+ function route(allowed, handler) {
59
+ return async (request, response) => {
60
+ if (allowed.length > 0 && !allowed.includes(request.method)) {
61
+ sendJson(response, 405, { ok: false, error: "method not allowed" }, request);
62
+ return;
63
+ }
64
+ try {
65
+ await handler(request, response);
66
+ } catch (error) {
67
+ sendJson(response, 500, { ok: false, error: String(error?.message ?? error) }, request);
68
+ }
69
+ };
70
+ }
71
+ function queryFlag(url, key) {
72
+ return url.searchParams.get(key) === "1" || url.searchParams.get(key) === "true";
73
+ }
74
+ function registerRoutes(rt) {
75
+ const { ctx, service } = rt;
76
+ const webServer = ctx.get("webServer");
77
+ if (!webServer || typeof webServer.register !== "function") {
78
+ console.warn(`[${NS}] 宿主没有 webServer 服务,面板数据接口未注册。`);
79
+ return () => {
80
+ };
81
+ }
82
+ const disposers = [];
83
+ const add = (path, allowed, handler) => {
84
+ disposers.push(webServer.register({ kind: "exact", path, handler: route(allowed, handler) }));
85
+ };
86
+ add(ROUTES.engineSelect, ["POST"], async (request, response) => {
87
+ const payload = await readJsonBody(request);
88
+ const status = await service.selectEngine(String(payload?.engine || "auto"));
89
+ sendJson(response, 200, status, request);
90
+ });
91
+ add(ROUTES.status, ["GET"], async (_request, response) => {
92
+ sendJson(response, 200, await service.status(), _request);
93
+ });
94
+ add(ROUTES.containers, ["GET"], async (request, response) => {
95
+ const url = new URL(request.url || "/", "http://127.0.0.1");
96
+ const containers = await service.containers(queryFlag(url, "all"));
97
+ sendJson(response, 200, { ok: true, containers }, request);
98
+ });
99
+ add(ROUTES.action, ["POST"], async (request, response) => {
100
+ const payload = await readJsonBody(request);
101
+ const result = await service.action(String(payload?.id || ""), String(payload?.action || ""));
102
+ sendJson(response, 200, result, request);
103
+ });
104
+ add(ROUTES.logs, ["GET"], async (request, response) => {
105
+ const url = new URL(request.url || "/", "http://127.0.0.1");
106
+ const id = String(url.searchParams.get("id") || "");
107
+ const tail = Number(url.searchParams.get("tail")) || void 0;
108
+ if (!id) {
109
+ sendJson(response, 400, { ok: false, error: "缺少容器 id" }, request);
110
+ return;
111
+ }
112
+ const text = await service.logs(id, tail);
113
+ sendJson(response, 200, { ok: true, text }, request);
114
+ });
115
+ add(ROUTES.run, ["POST"], async (request, response) => {
116
+ const payload = await readJsonBody(request);
117
+ const result = await service.run({
118
+ image: payload?.image,
119
+ name: payload?.name || void 0,
120
+ ports: Array.isArray(payload?.ports) ? payload.ports : [],
121
+ env: Array.isArray(payload?.env) ? payload.env : [],
122
+ cmd: payload?.cmd
123
+ });
124
+ sendJson(response, 200, result, request);
125
+ });
126
+ add(ROUTES.images, ["GET"], async (request, response) => {
127
+ const images = await service.images();
128
+ sendJson(response, 200, { ok: true, images }, request);
129
+ });
130
+ add(ROUTES.pull, ["POST"], async (request, response) => {
131
+ const payload = await readJsonBody(request);
132
+ const ref = String(payload?.ref || "").trim();
133
+ if (!ref) {
134
+ sendJson(response, 400, { ok: false, error: "缺少镜像引用" }, request);
135
+ return;
136
+ }
137
+ const result = await service.pull(ref);
138
+ sendJson(response, 200, result, request);
139
+ });
140
+ add(ROUTES.imageAction, ["POST"], async (request, response) => {
141
+ const payload = await readJsonBody(request);
142
+ const result = await service.imageAction(String(payload?.action || ""), payload || {});
143
+ sendJson(response, 200, result, request);
144
+ });
145
+ add(ROUTES.imageSearch, ["GET"], async (request, response) => {
146
+ const url = new URL(request.url || "/", "http://127.0.0.1");
147
+ const term = String(url.searchParams.get("term") || "").trim();
148
+ if (!term) {
149
+ sendJson(response, 400, { ok: false, error: "缺少搜索词" }, request);
150
+ return;
151
+ }
152
+ const results = await service.searchImages(term, Number(url.searchParams.get("limit")) || 10);
153
+ sendJson(response, 200, { ok: true, results }, request);
154
+ });
155
+ add(ROUTES.df, ["GET"], async (request, response) => {
156
+ sendJson(response, 200, await service.systemDf(), request);
157
+ });
158
+ add(ROUTES.imageHubSearch, ["GET"], async (request, response) => {
159
+ const url = new URL(request.url || "/", "http://127.0.0.1");
160
+ const term = String(url.searchParams.get("term") || "").trim();
161
+ if (!term) {
162
+ sendJson(response, 400, { ok: false, error: "缺少搜索词" }, request);
163
+ return;
164
+ }
165
+ const payload = await service.searchHubImages(term, Number(url.searchParams.get("limit")) || 25);
166
+ sendJson(response, 200, { ok: true, ...payload }, request);
167
+ });
168
+ add(ROUTES.imageTags, ["GET"], async (request, response) => {
169
+ const url = new URL(request.url || "/", "http://127.0.0.1");
170
+ const name = String(url.searchParams.get("name") || "").trim();
171
+ if (!name) {
172
+ sendJson(response, 400, { ok: false, error: "缺少镜像名" }, request);
173
+ return;
174
+ }
175
+ sendJson(response, 200, { ok: true, ...await service.imageTags(name) }, request);
176
+ });
177
+ add(ROUTES.imageInspect, ["GET"], async (request, response) => {
178
+ const url = new URL(request.url || "/", "http://127.0.0.1");
179
+ const ref = String(url.searchParams.get("ref") || "").trim();
180
+ if (!ref) {
181
+ sendJson(response, 400, { ok: false, error: "缺少镜像名" }, request);
182
+ return;
183
+ }
184
+ sendJson(response, 200, await service.inspectImage(ref), request);
185
+ });
186
+ add(ROUTES.stats, ["GET"], async (request, response) => {
187
+ const url = new URL(request.url || "/", "http://127.0.0.1");
188
+ const ids = String(url.searchParams.get("ids") || "").split(",").map((id) => id.trim()).filter(Boolean);
189
+ const stats = await service.runningStats(ids);
190
+ sendJson(response, 200, { ok: true, stats }, request);
191
+ });
192
+ add(ROUTES.volumes, ["GET"], async (request, response) => {
193
+ const volumes = await service.volumes();
194
+ sendJson(response, 200, { ok: true, volumes }, request);
195
+ });
196
+ add(ROUTES.volumeAction, ["POST"], async (request, response) => {
197
+ const payload = await readJsonBody(request);
198
+ const result = await service.volumeAction(String(payload?.action || ""), payload || {});
199
+ sendJson(response, 200, result, request);
200
+ });
201
+ add(ROUTES.networks, ["GET"], async (request, response) => {
202
+ const networks = await service.networks();
203
+ sendJson(response, 200, { ok: true, networks }, request);
204
+ });
205
+ add(ROUTES.networkAction, ["POST"], async (request, response) => {
206
+ const payload = await readJsonBody(request);
207
+ const result = await service.networkAction(String(payload?.action || ""), payload || {});
208
+ sendJson(response, 200, result, request);
209
+ });
210
+ return () => {
211
+ for (const dispose of disposers) dispose();
212
+ };
213
+ }
214
+
215
+ // packages/dsh-containers-ui/src/host/index.js
216
+ var inject = ["containers", "webServer"];
217
+ function apply(ctx, config = {}) {
218
+ const service = ctx.containers;
219
+ const disposeRoutes = registerRoutes({ ctx, service, config });
220
+ ctx.effect(() => () => disposeRoutes());
221
+ }
222
+ export {
223
+ apply,
224
+ inject
225
+ };
@@ -0,0 +1,283 @@
1
+ // packages/dsh-containers-tools/src/host/tools.js
2
+ import { defineTool } from "@deepseek-ai/dsh-tools";
3
+
4
+ // packages/dsh-containers-core/shared/kiri-domain.js
5
+ var KIRI_DOMAIN_LABEL = "dev.kiri.domain";
6
+ function kiriDomain(container) {
7
+ const custom = container?.labels?.[KIRI_DOMAIN_LABEL];
8
+ if (custom) return String(custom);
9
+ const name = String(container?.name || "").trim();
10
+ return name ? `${name}.kiri.local` : "";
11
+ }
12
+
13
+ // packages/dsh-containers-tools/src/host/tools.js
14
+ var TEXT_OUTPUT = {
15
+ schema: { type: "string" },
16
+ render: (_args, value) => [{ type: "text", text: value }]
17
+ };
18
+ function clip(text, max = 4e3) {
19
+ return text.length <= max ? text : `${text.slice(0, max)}
20
+ …(已截断,共 ${text.length} 字符)`;
21
+ }
22
+ function formatStatus(info) {
23
+ if (!info.connected && info.starting) {
24
+ return `容器引擎未连接,正在后台启动 ${info.startRuntime || "引擎"}(首次启动可能需要几十秒):${info.error}`;
25
+ }
26
+ if (!info.connected) return `容器引擎不可用:${info.error}`;
27
+ return [
28
+ `已连接 ${info.engineLabel}(端点 ${info.endpoint})`,
29
+ `引擎版本 ${info.version || "未知"},API ${info.apiVersion || "未知"}`
30
+ ].join(";");
31
+ }
32
+ function formatContainers(list, withKiriDomain = false) {
33
+ if (list.length === 0) return "(没有容器)";
34
+ const rows = list.slice(0, 100).map((item) => {
35
+ const ports = item.ports.length ? ` ports=${item.ports.join(",")}` : "";
36
+ const domain = withKiriDomain && item.state === "running" ? ` domain=http://${kiriDomain(item) || "-"}` : "";
37
+ return `${item.id} ${item.name || "-"} ${item.image} ${item.state}(${item.status})${ports}${domain}`;
38
+ });
39
+ return clip(`共 ${list.length} 个容器:
40
+ ${rows.join("\n")}`);
41
+ }
42
+ function formatImages(list) {
43
+ if (list.length === 0) return "(没有镜像)";
44
+ const rows = list.slice(0, 100).map((item) => {
45
+ const tag = item.tags.length ? item.tags[0] : `${item.repo}:<none>`;
46
+ return `${item.id} ${tag} ${(item.size / 1048576).toFixed(1)} MB`;
47
+ });
48
+ return clip(`共 ${list.length} 个镜像:
49
+ ${rows.join("\n")}`);
50
+ }
51
+ var inject = ["tools", "containers"];
52
+ function apply(ctx, config = {}) {
53
+ const service = ctx.containers;
54
+ ctx.tools.register(defineTool({
55
+ name: "containers_status",
56
+ description: "查看本机容器引擎(kiri / Docker)的连接状态与版本。引擎未启动时会给出后台启动进度。",
57
+ parameters: {},
58
+ output: TEXT_OUTPUT,
59
+ async execute() {
60
+ return formatStatus(await service.status());
61
+ }
62
+ }));
63
+ ctx.tools.register(defineTool({
64
+ name: "containers_engine",
65
+ description: "查询或切换面板使用的容器引擎(kiri ⇄ Docker Desktop ⇄ 自动)。不带 engine 参数时仅查询当前状态;切换后面板与各容器工具立即跟随新引擎。",
66
+ parameters: {
67
+ engine: { type: "string", description: "auto | kiri | docker;缺省仅查询" }
68
+ },
69
+ output: TEXT_OUTPUT,
70
+ async execute(args) {
71
+ const info = args.engine ? await service.selectEngine(String(args.engine)) : await service.status();
72
+ const engines = info.engines || {};
73
+ const state = (item) => item && item.online ? "在线(" + (item.version || "版本未知") + ")" : "离线";
74
+ return [
75
+ args.engine ? "已切换引擎选择:" + info.engineChoice : "当前引擎选择:" + info.engineChoice,
76
+ formatStatus(info),
77
+ "可选引擎:kiri " + state(engines.kiri) + ";docker " + state(engines.docker)
78
+ ].join("\n");
79
+ }
80
+ }));
81
+ ctx.tools.register(defineTool({
82
+ name: "containers_ps",
83
+ description: "列出本机容器:id、名称、镜像、状态与端口映射。引擎未启动时会自动拉起并等待就绪。",
84
+ parameters: {
85
+ all: { type: "boolean", description: "是否包含已停止的容器,默认 true" }
86
+ },
87
+ output: TEXT_OUTPUT,
88
+ async execute(args) {
89
+ await service.ensureReady();
90
+ const [info, list] = await Promise.all([service.status(), service.containers(args.all !== false)]);
91
+ return formatContainers(list, info.engineLabel === "kiri");
92
+ }
93
+ }));
94
+ ctx.tools.register(defineTool({
95
+ name: "containers_container_action",
96
+ description: "对容器执行一个动作:start / stop / restart / pause / unpause / kill / remove。remove 会连带删除匿名卷。",
97
+ parameters: {
98
+ id: { type: "string", required: true, description: "容器 id 或名称(containers_ps 返回的短 id 即可)" },
99
+ action: { type: "string", required: true, description: "start | stop | restart | pause | unpause | kill | remove" }
100
+ },
101
+ output: TEXT_OUTPUT,
102
+ async execute(args) {
103
+ await service.ensureReady();
104
+ const result = await service.action(args.id, args.action);
105
+ return `${result.action} ${result.id}:完成`;
106
+ }
107
+ }));
108
+ ctx.tools.register(defineTool({
109
+ name: "containers_logs",
110
+ description: "读取容器日志(stdout+stderr 合并,末尾 N 行)。",
111
+ parameters: {
112
+ id: { type: "string", required: true, description: "容器 id 或名称" },
113
+ tail: { type: "number", description: "返回末尾多少行,默认取插件配置 logTail" }
114
+ },
115
+ output: TEXT_OUTPUT,
116
+ async execute(args) {
117
+ await service.ensureReady();
118
+ return clip(await service.logs(args.id, args.tail));
119
+ }
120
+ }));
121
+ ctx.tools.register(defineTool({
122
+ name: "containers_run",
123
+ description: "创建并启动一个容器(等价 docker run -d);镜像不存在时自动先拉取。",
124
+ parameters: {
125
+ image: { type: "string", required: true, description: "镜像引用,如 alpine:latest" },
126
+ name: { type: "string", description: "容器名,缺省由引擎生成" },
127
+ ports: { type: "string", description: '端口映射,逗号分隔,如 "8080:80,9000:9000/udp"' },
128
+ env: { type: "string", description: '环境变量,逗号分隔,如 "KEY=value,FOO=bar"' },
129
+ cmd: { type: "string", description: "容器内 shell 命令,以 sh -c 执行;缺省用镜像入口" }
130
+ },
131
+ output: TEXT_OUTPUT,
132
+ async execute(args) {
133
+ await service.ensureReady();
134
+ const split = (raw) => String(raw || "").split(",").map((item) => item.trim()).filter(Boolean);
135
+ const result = await service.run({
136
+ image: args.image,
137
+ name: args.name,
138
+ ports: split(args.ports),
139
+ env: split(args.env),
140
+ cmd: args.cmd ? ["sh", "-c", String(args.cmd)] : void 0
141
+ });
142
+ return `容器已启动:${result.name || result.id}(id ${result.id})`;
143
+ }
144
+ }));
145
+ ctx.tools.register(defineTool({
146
+ name: "containers_images",
147
+ description: "镜像管理:列出本机镜像、拉取、删除、打标签、清理悬空镜像。",
148
+ parameters: {
149
+ action: { type: "string", description: "list(默认)| pull | remove | tag | prune" },
150
+ ref: { type: "string", description: "pull 的镜像引用 / remove 的镜像 id 或名称 / tag 的源镜像 id" },
151
+ repo: { type: "string", description: "action=tag 的新镜像名" },
152
+ newTag: { type: "string", description: "action=tag 的新标签,默认 latest" },
153
+ all: { type: "string", description: 'action=prune 时 "1" 表示连未使用的镜像一起清(默认只清悬空层)' }
154
+ },
155
+ output: TEXT_OUTPUT,
156
+ async execute(args) {
157
+ await service.ensureReady();
158
+ const action = String(args.action || "list");
159
+ if (action === "pull") {
160
+ if (!args.ref) throw new Error("action=pull 需要 ref 参数");
161
+ const result = await service.pull(args.ref);
162
+ return `镜像拉取完成:${result.ref}(${result.status || "done"})`;
163
+ }
164
+ if (action === "remove") {
165
+ if (!args.ref) throw new Error("action=remove 需要 ref 参数(镜像 id 或名称)");
166
+ await service.imageAction("remove", { id: args.ref });
167
+ return `镜像已删除:${args.ref}`;
168
+ }
169
+ if (action === "tag") {
170
+ if (!args.ref || !args.repo) throw new Error("action=tag 需要 ref(源镜像)与 repo(新名称)参数");
171
+ const result = await service.imageAction("tag", { id: args.ref, repo: args.repo, tag: args.newTag });
172
+ return `已打标签:${args.ref} → ${result.ref}`;
173
+ }
174
+ if (action === "prune") {
175
+ const result = await service.imageAction("prune", { all: args.all === "1" });
176
+ const mb = (result.spaceReclaimed / 1048576).toFixed(1);
177
+ return `清理完成:删除 ${result.removed} 项,释放 ${mb} MB`;
178
+ }
179
+ return formatImages(await service.images());
180
+ }
181
+ }));
182
+ ctx.tools.register(defineTool({
183
+ name: "containers_volumes",
184
+ description: "卷管理:列出本机卷、创建、删除、清理未使用的卷。",
185
+ parameters: {
186
+ action: { type: "string", description: "list(默认)| create | remove | prune" },
187
+ name: { type: "string", description: "create / remove 的卷名称" },
188
+ driver: { type: "string", description: "create 的卷驱动,默认引擎默认(local)" }
189
+ },
190
+ output: TEXT_OUTPUT,
191
+ async execute(args) {
192
+ await service.ensureReady();
193
+ const action = String(args.action || "list");
194
+ if (action === "create") {
195
+ if (!args.name) throw new Error("action=create 需要 name 参数");
196
+ await service.volumeAction("create", { name: args.name, driver: args.driver });
197
+ return `卷已创建:${args.name}`;
198
+ }
199
+ if (action === "remove") {
200
+ if (!args.name) throw new Error("action=remove 需要 name 参数");
201
+ await service.volumeAction("remove", { name: args.name });
202
+ return `卷已删除:${args.name}`;
203
+ }
204
+ if (action === "prune") {
205
+ const result = await service.volumeAction("prune", {});
206
+ const mb = (result.spaceReclaimed / 1048576).toFixed(1);
207
+ return `清理完成:删除 ${result.removed} 个未使用的卷,释放 ${mb} MB`;
208
+ }
209
+ const list = await service.volumes();
210
+ if (list.length === 0) return "(没有卷)";
211
+ return clip(`共 ${list.length} 个卷:
212
+ ${list.slice(0, 100).map((item) => `${item.name} ${item.driver}`).join("\n")}`);
213
+ }
214
+ }));
215
+ ctx.tools.register(defineTool({
216
+ name: "containers_networks",
217
+ description: "网络管理:列出本机网络、创建、删除网络。",
218
+ parameters: {
219
+ action: { type: "string", description: "list(默认)| create | remove" },
220
+ name: { type: "string", description: "create 的网络名称 / remove 的网络 id" },
221
+ driver: { type: "string", description: "create 的网络驱动,默认 bridge" }
222
+ },
223
+ output: TEXT_OUTPUT,
224
+ async execute(args) {
225
+ await service.ensureReady();
226
+ const action = String(args.action || "list");
227
+ if (action === "create") {
228
+ if (!args.name) throw new Error("action=create 需要 name 参数");
229
+ await service.networkAction("create", { name: args.name, driver: args.driver });
230
+ return `网络已创建:${args.name}`;
231
+ }
232
+ if (action === "remove") {
233
+ if (!args.name) throw new Error("action=remove 需要 name 参数(网络 id)");
234
+ await service.networkAction("remove", { id: args.name });
235
+ return `网络已删除:${args.name}`;
236
+ }
237
+ const list = await service.networks();
238
+ if (list.length === 0) return "(没有网络)";
239
+ return clip(`共 ${list.length} 个网络:
240
+ ${list.slice(0, 100).map((item) => `${item.name} ${item.driver} ${item.containerCount} 个容器${item.internal ? " internal" : ""}`).join("\n")}`);
241
+ }
242
+ }));
243
+ ctx.tools.register(defineTool({
244
+ name: "containers_df",
245
+ description: "查看引擎磁盘概览(等价 docker system df):镜像/容器/卷的数量与占用空间。",
246
+ parameters: {},
247
+ output: TEXT_OUTPUT,
248
+ async execute() {
249
+ await service.ensureReady();
250
+ const df = await service.systemDf();
251
+ const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
252
+ return `镜像 ${df.images.count} 个(${mb(df.images.size)});容器 ${df.containers.count} 个(${mb(df.containers.size)});卷 ${df.volumes.count} 个(${mb(df.volumes.size)})`;
253
+ }
254
+ }));
255
+ ctx.tools.register(defineTool({
256
+ name: "containers_search",
257
+ description: "在镜像仓库(Docker Hub)搜索镜像:名称、描述、星标数、是否官方。",
258
+ parameters: {
259
+ term: { type: "string", required: true, description: "搜索词" },
260
+ limit: { type: "string", description: "返回条数,默认 10,最多 25" }
261
+ },
262
+ output: TEXT_OUTPUT,
263
+ async execute(args) {
264
+ const limit = Number(args.limit) || 10;
265
+ let list;
266
+ try {
267
+ const payload = await service.searchHubImages(args.term, limit);
268
+ list = payload.results;
269
+ } catch (error) {
270
+ await service.ensureReady();
271
+ list = await service.searchImages(args.term, limit);
272
+ }
273
+ if (list.length === 0) return "(没有搜索结果)";
274
+ const pulls = (item) => item.pulls == null ? "" : ` 下载 ${item.pulls}`;
275
+ return clip(`搜索 "${args.term}":
276
+ ${list.map((item) => `${item.name} ★${item.stars}${item.official ? " [官方]" : ""}${pulls(item)} ${String(item.description || "").slice(0, 60)}`).join("\n")}`);
277
+ }
278
+ }));
279
+ }
280
+ export {
281
+ apply,
282
+ inject
283
+ };
package/icon.svg ADDED
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <rect x="10" y="42" width="44" height="10" rx="5" fill="#3358E4"/>
3
+ <rect x="17" y="27" width="30" height="10" rx="5" fill="#5C7CFA"/>
4
+ <rect x="24" y="12" width="16" height="10" rx="5" fill="#91A7FF"/>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Container engine core",
4
+ "description": "Remote-sensing agent base plugin: container engine (kiri/Docker) capability seam — the ctx.containers engine-primitive service for other plugins to inject; headless."
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "容器引擎核心",
4
+ "description": "遥感智能体基础插件:容器引擎(kiri/Docker)能力 seam——引擎原语服务 ctx.containers,供其他插件注入;无界面。"
5
+ }
6
+ }