dsh-aperture 0.1.0 → 0.2.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.
- package/LICENSE +21 -21
- package/README.en.md +155 -207
- package/README.md +156 -195
- package/client/aperture.js +1522 -0
- package/cordis.patch.yml +3 -2
- package/lib/index.d.ts +11 -2
- package/lib/index.js +18 -5
- package/lib/panel.d.ts +113 -0
- package/lib/panel.js +271 -0
- package/lib/registry.d.ts +1 -5
- package/lib/registry.js +0 -14
- package/lib/remote.d.ts +79 -0
- package/lib/remote.js +120 -0
- package/lib/report.d.ts +111 -9
- package/lib/report.js +107 -79
- package/lib/runtime.d.ts +4 -9
- package/lib/runtime.js +6 -23
- package/lib/types.d.ts +1 -1
- package/package.json +20 -9
- package/lib/command.d.ts +0 -21
- package/lib/command.js +0 -58
package/lib/command.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `/aperture` 命令。
|
|
3
|
-
*
|
|
4
|
-
* 发现过程按设计是静默的——它在加载时与配置变更时运行,并发布自己发现的内容——因此
|
|
5
|
-
* 该命令是让它可被观测的界面,也是不编辑文件就能强制刷新的唯一途径。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-aperture/command
|
|
8
|
-
*/
|
|
9
|
-
import { formatModels, formatStatus } from "./report.js";
|
|
10
|
-
import { message } from "./runtime.js";
|
|
11
|
-
/** 注册的命令名,不含前导斜杠。 */
|
|
12
|
-
export const COMMAND_NAME = 'aperture';
|
|
13
|
-
/** 该命令接受的子命令。 */
|
|
14
|
-
const USAGE = [
|
|
15
|
-
'用法:/aperture [status|models|refresh|remove]',
|
|
16
|
-
' status 最近一次刷新做了什么(默认)',
|
|
17
|
-
' models 每个已发现的模型、它所在的路由,以及每条事实的来源',
|
|
18
|
-
' refresh 重新发现并重新发布',
|
|
19
|
-
' remove 从 llm-pi-ai 设置配置段中撤出本插件的路由',
|
|
20
|
-
].join('\n');
|
|
21
|
-
/**
|
|
22
|
-
* 在命令注册表上注册 `/aperture`。
|
|
23
|
-
*
|
|
24
|
-
* @param ctx - 带有 `commands` 服务的上下文。
|
|
25
|
-
* @param runtime - 发现运行时。
|
|
26
|
-
* @param config - 返回当前生效配置的活引用(thunk)。
|
|
27
|
-
*/
|
|
28
|
-
export function registerApertureCommand(ctx, runtime, config) {
|
|
29
|
-
ctx.commands.register({
|
|
30
|
-
name: COMMAND_NAME,
|
|
31
|
-
description: 'Aperture 模型发现:状态、已发现的模型、刷新、移除',
|
|
32
|
-
recordInput: false,
|
|
33
|
-
handler: async ({ rawInput }) => {
|
|
34
|
-
const [subCommand] = rawInput.trim().split(/\s+/u).filter((token) => token.length > 0);
|
|
35
|
-
try {
|
|
36
|
-
switch (subCommand) {
|
|
37
|
-
case undefined:
|
|
38
|
-
case 'status':
|
|
39
|
-
return { kind: 'success', text: formatStatus(runtime.last(), config()) };
|
|
40
|
-
case 'models':
|
|
41
|
-
return { kind: 'success', text: formatModels(runtime.last()) };
|
|
42
|
-
case 'refresh': {
|
|
43
|
-
const outcome = await runtime.refresh('命令');
|
|
44
|
-
const text = formatStatus(outcome, config());
|
|
45
|
-
return outcome.ok ? { kind: 'success', text } : { kind: 'error', text };
|
|
46
|
-
}
|
|
47
|
-
case 'remove':
|
|
48
|
-
return { kind: 'success', text: await runtime.remove() };
|
|
49
|
-
default:
|
|
50
|
-
return { kind: 'error', text: `未知子命令 "${subCommand}"\n${USAGE}` };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return { kind: 'error', text: `/aperture ${subCommand ?? ''} 执行失败:${message(error)}` };
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|