cortico 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.
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/package.json +43 -0
- package/src/boot.ts +46 -0
- package/src/bot.ts +1342 -0
- package/src/config-file.ts +41 -0
- package/src/core/README.md +92 -0
- package/src/core/billing.ts +26 -0
- package/src/core/blobs.ts +106 -0
- package/src/core/bus.ts +311 -0
- package/src/core/config-schema.ts +201 -0
- package/src/core/config.ts +262 -0
- package/src/core/core.ts +699 -0
- package/src/core/cost.ts +244 -0
- package/src/core/event-store.ts +304 -0
- package/src/core/fork.ts +113 -0
- package/src/core/generation.ts +118 -0
- package/src/core/instance-lock.ts +215 -0
- package/src/core/ipc-logger.ts +105 -0
- package/src/core/language.ts +62 -0
- package/src/core/log-context.ts +38 -0
- package/src/core/loop.ts +1858 -0
- package/src/core/markers.ts +48 -0
- package/src/core/prefix.ts +121 -0
- package/src/core/run.ts +95 -0
- package/src/core/secrets.ts +18 -0
- package/src/core/session.ts +56 -0
- package/src/core/sessions.ts +261 -0
- package/src/core/state.ts +104 -0
- package/src/core/template.ts +72 -0
- package/src/core/timers.ts +129 -0
- package/src/core/tool-log.ts +135 -0
- package/src/core/transcript.ts +92 -0
- package/src/core/truncate.ts +121 -0
- package/src/core/types.ts +1140 -0
- package/src/core/usage-log.ts +79 -0
- package/src/core/util.ts +386 -0
- package/src/deploy-listing.ts +160 -0
- package/src/deploy.ts +162 -0
- package/src/extensions/README.md +72 -0
- package/src/extensions/dry-mount.ts +390 -0
- package/src/extensions/manifest.ts +153 -0
- package/src/extensions/runtime.ts +42 -0
- package/src/extensions.ts +519 -0
- package/src/launcher.ts +285 -0
- package/src/paths.ts +155 -0
- package/src/protocol/open-responses/LICENSE +201 -0
- package/src/protocol/open-responses/README.md +14 -0
- package/src/protocol/open-responses/context-helpers.ts +27 -0
- package/src/protocol/open-responses/context-log.ts +59 -0
- package/src/protocol/open-responses/context.ts +89 -0
- package/src/protocol/open-responses/generated.ts +115 -0
- package/src/protocol/open-responses/index.ts +33 -0
- package/src/protocol/open-responses/openapi.json +4230 -0
- package/src/protocol/open-responses/stream.ts +146 -0
- package/src/protocol/open-responses/tokens.ts +31 -0
- package/src/providers/README.md +86 -0
- package/src/providers/base.ts +111 -0
- package/src/providers/configuration.ts +97 -0
- package/src/providers/console/config.ts +21 -0
- package/src/providers/console/settings.ts +443 -0
- package/src/providers/console/strings.ts +74 -0
- package/src/providers/console/types.ts +11 -0
- package/src/providers/llamacpp/archive.ts +148 -0
- package/src/providers/llamacpp/catalog.ts +247 -0
- package/src/providers/llamacpp/config.ts +36 -0
- package/src/providers/llamacpp/console/client.ts +6 -0
- package/src/providers/llamacpp/console/models-panel.ts +120 -0
- package/src/providers/llamacpp/console/runtime-panel.ts +173 -0
- package/src/providers/llamacpp/console/server.ts +153 -0
- package/src/providers/llamacpp/index.ts +95 -0
- package/src/providers/llamacpp/native.ts +51 -0
- package/src/providers/llamacpp/options.ts +117 -0
- package/src/providers/llamacpp/runtime-store.ts +139 -0
- package/src/providers/llamacpp/runtime.ts +214 -0
- package/src/providers/llamacpp/server.ts +286 -0
- package/src/providers/llamacpp/strings.ts +230 -0
- package/src/providers/openai-responses-compat/config.ts +20 -0
- package/src/providers/openai-responses-compat/index.ts +89 -0
- package/src/providers/openai-responses-compat/native.ts +127 -0
- package/src/providers/openai-responses-compat/strings.ts +19 -0
- package/src/providers/pricebook.ts +75 -0
- package/src/providers/registry.ts +137 -0
- package/src/providers/strings.ts +71 -0
- package/src/providers/transport/chat.ts +156 -0
- package/src/providers/transport/errors.ts +48 -0
- package/src/providers/transport/history.ts +68 -0
- package/src/providers/transport/native-input.ts +83 -0
- package/src/providers/transport/native-types.ts +13 -0
- package/src/providers/transport/response-assembly.ts +191 -0
- package/src/providers/transport/response-http.ts +196 -0
- package/src/providers/transport/response-meters.ts +27 -0
- package/src/providers/transport/responses-input.ts +56 -0
- package/src/web/README.md +84 -0
- package/src/web/client/console-pages/builtins/llm-settings/panel.ts +625 -0
- package/src/web/client/console-pages/builtins/llm-settings/pricing-panel.ts +168 -0
- package/src/web/client/console-pages/builtins/llm-settings/strings.ts +213 -0
- package/src/web/client/console-pages/builtins.ts +10 -0
- package/src/web/client/console-pages/context.ts +135 -0
- package/src/web/client/console-pages/host.ts +633 -0
- package/src/web/client/console-pages/loader.ts +132 -0
- package/src/web/client/console-pages/strings.ts +90 -0
- package/src/web/client/console-pages/tools/strings.ts +49 -0
- package/src/web/client/console-pages/tools/view.ts +215 -0
- package/src/web/client/core/api.ts +200 -0
- package/src/web/client/core/language.ts +56 -0
- package/src/web/client/core/lifecycle.ts +132 -0
- package/src/web/client/core/router.ts +199 -0
- package/src/web/client/core/stream.ts +157 -0
- package/src/web/client/core/websocket.ts +82 -0
- package/src/web/client/features/appearance/index.ts +333 -0
- package/src/web/client/features/appearance/strings.ts +87 -0
- package/src/web/client/features/config/index.ts +11 -0
- package/src/web/client/features/config/strings.ts +41 -0
- package/src/web/client/features/config/view.ts +428 -0
- package/src/web/client/features/core/events.ts +197 -0
- package/src/web/client/features/core/index.ts +254 -0
- package/src/web/client/features/core/run.ts +56 -0
- package/src/web/client/features/core/runlog.ts +214 -0
- package/src/web/client/features/core/sessions.ts +53 -0
- package/src/web/client/features/core/strings.ts +157 -0
- package/src/web/client/features/extensions/index.ts +422 -0
- package/src/web/client/features/extensions/strings.ts +164 -0
- package/src/web/client/features/feature.ts +93 -0
- package/src/web/client/features/live/context.ts +280 -0
- package/src/web/client/features/live/fork.ts +156 -0
- package/src/web/client/features/live/index.ts +392 -0
- package/src/web/client/features/live/onboarding.ts +113 -0
- package/src/web/client/features/live/protocol.ts +122 -0
- package/src/web/client/features/live/sessions.ts +71 -0
- package/src/web/client/features/live/status.ts +68 -0
- package/src/web/client/features/live/strings.ts +252 -0
- package/src/web/client/features/live/timeline.ts +590 -0
- package/src/web/client/features/prompts/editor.ts +292 -0
- package/src/web/client/features/prompts/index.ts +346 -0
- package/src/web/client/features/prompts/strings.ts +136 -0
- package/src/web/client/features/prompts/view.ts +256 -0
- package/src/web/client/features/providers/index.ts +100 -0
- package/src/web/client/features/providers/strings.ts +23 -0
- package/src/web/client/features/settings/general.ts +28 -0
- package/src/web/client/features/settings/index.ts +82 -0
- package/src/web/client/features/settings/strings.ts +33 -0
- package/src/web/client/features/storage/index.ts +1 -0
- package/src/web/client/features/storage/strings.ts +45 -0
- package/src/web/client/features/storage/view.ts +154 -0
- package/src/web/client/features/usage/chart.ts +486 -0
- package/src/web/client/features/usage/index.ts +407 -0
- package/src/web/client/features/usage/labels.ts +46 -0
- package/src/web/client/features/usage/range.ts +36 -0
- package/src/web/client/features/usage/state.ts +37 -0
- package/src/web/client/features/usage/strings.ts +191 -0
- package/src/web/client/features/usage/tooltip.ts +86 -0
- package/src/web/client/features/usage/types.ts +96 -0
- package/src/web/client/features/worlds/index.ts +424 -0
- package/src/web/client/features/worlds/strings.ts +121 -0
- package/src/web/client/main.ts +273 -0
- package/src/web/client/shell/avatar.ts +233 -0
- package/src/web/client/shell/index.ts +549 -0
- package/src/web/client/shell/strings.ts +89 -0
- package/src/web/client/theme/handoff.ts +43 -0
- package/src/web/client/theme/palette.ts +109 -0
- package/src/web/client/theme/registry.ts +130 -0
- package/src/web/client/theme/storage.ts +72 -0
- package/src/web/client/theme/strings.ts +123 -0
- package/src/web/client/theme/studio.ts +366 -0
- package/src/web/client/ui/actions.ts +109 -0
- package/src/web/client/ui/data.ts +185 -0
- package/src/web/client/ui/dom.ts +23 -0
- package/src/web/client/ui/fields.ts +191 -0
- package/src/web/client/ui/format.ts +75 -0
- package/src/web/client/ui/icons.ts +183 -0
- package/src/web/client/ui/images.ts +91 -0
- package/src/web/client/ui/index.ts +89 -0
- package/src/web/client/ui/lamp.ts +125 -0
- package/src/web/client/ui/log.ts +98 -0
- package/src/web/client/ui/overlay.ts +184 -0
- package/src/web/client/ui/page.ts +8 -0
- package/src/web/client/ui/prompt-input.tsx +311 -0
- package/src/web/client/ui/sheet.ts +131 -0
- package/src/web/client/ui/strings.ts +71 -0
- package/src/web/console-pages.ts +367 -0
- package/src/web/files.ts +107 -0
- package/src/web/path-picker.ts +296 -0
- package/src/web/public/index.html +17 -0
- package/src/web/public/styles.css +1715 -0
- package/src/web/server.ts +1883 -0
- package/src/web/shared/client-panel.ts +603 -0
- package/src/web/shared/console-protocol.ts +560 -0
- package/src/web/shared/css.d.ts +1 -0
- package/src/web/shared/path-picker.ts +23 -0
- package/src/web/shared/theme.ts +256 -0
- package/src/web/theme-store.ts +37 -0
- package/src/world.ts +449 -0
- package/src/worlds/bilibili/ENV_PROMPT.md +5 -0
- package/src/worlds/bilibili/README.md +176 -0
- package/src/worlds/bilibili/audience-admission.ts +995 -0
- package/src/worlds/bilibili/client.ts +528 -0
- package/src/worlds/bilibili/coalescing-buffer.ts +125 -0
- package/src/worlds/bilibili/config.ts +185 -0
- package/src/worlds/bilibili/console/client.ts +202 -0
- package/src/worlds/bilibili/definition.ts +35 -0
- package/src/worlds/bilibili/gift-frame.ts +131 -0
- package/src/worlds/bilibili/normalize.ts +452 -0
- package/src/worlds/bilibili/overlay/announcement.ts +76 -0
- package/src/worlds/bilibili/overlay/assets.ts +82 -0
- package/src/worlds/bilibili/overlay/model.ts +494 -0
- package/src/worlds/bilibili/overlay/project.ts +202 -0
- package/src/worlds/bilibili/overlay/server.ts +286 -0
- package/src/worlds/bilibili/overlay/types.ts +217 -0
- package/src/worlds/bilibili/overlay/web/app.js +690 -0
- package/src/worlds/bilibili/overlay/web/editor.css +297 -0
- package/src/worlds/bilibili/overlay/web/editor.html +102 -0
- package/src/worlds/bilibili/overlay/web/editor.js +2116 -0
- package/src/worlds/bilibili/overlay/web/overlay.html +13 -0
- package/src/worlds/bilibili/overlay/web/styles.css +258 -0
- package/src/worlds/bilibili/protobuf.ts +123 -0
- package/src/worlds/bilibili/wire.ts +94 -0
- package/src/worlds/bilibili/world.ts +1389 -0
- package/src/worlds/console-fixture/ENV_PROMPT.md +1 -0
- package/src/worlds/console-fixture/console/client.ts +72 -0
- package/src/worlds/console-fixture/world.ts +73 -0
- package/src/worlds/index.ts +15 -0
- package/src/worlds/minecraft/ENV_PROMPT.md +32 -0
- package/src/worlds/minecraft/ENV_PROMPT_CAMERA.md +2 -0
- package/src/worlds/minecraft/LICENSE-mineflayer-pathfinder.txt +21 -0
- package/src/worlds/minecraft/README.md +917 -0
- package/src/worlds/minecraft/blueprint-plan.ts +915 -0
- package/src/worlds/minecraft/blueprint-registry.ts +566 -0
- package/src/worlds/minecraft/blueprint-repair.ts +236 -0
- package/src/worlds/minecraft/blueprint-resource.ts +272 -0
- package/src/worlds/minecraft/blueprint.ts +492 -0
- package/src/worlds/minecraft/body-lease.ts +340 -0
- package/src/worlds/minecraft/bridge.ts +749 -0
- package/src/worlds/minecraft/check.ts +651 -0
- package/src/worlds/minecraft/chests.ts +292 -0
- package/src/worlds/minecraft/client-launch.ts +272 -0
- package/src/worlds/minecraft/client-options.ts +85 -0
- package/src/worlds/minecraft/client-skins.ts +164 -0
- package/src/worlds/minecraft/client-window.ps1 +91 -0
- package/src/worlds/minecraft/client.ts +423 -0
- package/src/worlds/minecraft/combat-context.ts +109 -0
- package/src/worlds/minecraft/combat.ts +1552 -0
- package/src/worlds/minecraft/config.ts +499 -0
- package/src/worlds/minecraft/console/access.ts +218 -0
- package/src/worlds/minecraft/console/client.ts +244 -0
- package/src/worlds/minecraft/console/log.ts +110 -0
- package/src/worlds/minecraft/console/mount.ts +420 -0
- package/src/worlds/minecraft/console/skin.ts +257 -0
- package/src/worlds/minecraft/console/style.css +154 -0
- package/src/worlds/minecraft/console/world.ts +449 -0
- package/src/worlds/minecraft/deaths.ts +135 -0
- package/src/worlds/minecraft/definition.ts +18 -0
- package/src/worlds/minecraft/engine-child.ts +274 -0
- package/src/worlds/minecraft/engine-ipc.ts +98 -0
- package/src/worlds/minecraft/entity-facts.ts +132 -0
- package/src/worlds/minecraft/escape.ts +407 -0
- package/src/worlds/minecraft/executor.ts +14494 -0
- package/src/worlds/minecraft/explored.ts +156 -0
- package/src/worlds/minecraft/geometry.ts +205 -0
- package/src/worlds/minecraft/goal-plan.ts +647 -0
- package/src/worlds/minecraft/item-break.ts +126 -0
- package/src/worlds/minecraft/item-facts.ts +146 -0
- package/src/worlds/minecraft/item-pick.ts +67 -0
- package/src/worlds/minecraft/level-dat.ts +176 -0
- package/src/worlds/minecraft/log.ts +132 -0
- package/src/worlds/minecraft/mineflayer-fixes.ts +1180 -0
- package/src/worlds/minecraft/names.ts +377 -0
- package/src/worlds/minecraft/pathfinder-lib.d.ts +13 -0
- package/src/worlds/minecraft/pathfinder-perf.ts +796 -0
- package/src/worlds/minecraft/piglin.ts +49 -0
- package/src/worlds/minecraft/policy.ts +547 -0
- package/src/worlds/minecraft/precheck.ts +655 -0
- package/src/worlds/minecraft/proxy.ts +445 -0
- package/src/worlds/minecraft/ranged.ts +635 -0
- package/src/worlds/minecraft/readouts.ts +102 -0
- package/src/worlds/minecraft/round.ts +26 -0
- package/src/worlds/minecraft/search-observation.ts +92 -0
- package/src/worlds/minecraft/server-config.ts +467 -0
- package/src/worlds/minecraft/server.ts +658 -0
- package/src/worlds/minecraft/show.ts +84 -0
- package/src/worlds/minecraft/skills.ts +1763 -0
- package/src/worlds/minecraft/terrain.ts +1735 -0
- package/src/worlds/minecraft/window.ts +96 -0
- package/src/worlds/minecraft/works.ts +179 -0
- package/src/worlds/minecraft/world.ts +6438 -0
- package/src/worlds/qq/ENV_PROMPT.md +5 -0
- package/src/worlds/qq/config.ts +108 -0
- package/src/worlds/qq/console/client.ts +126 -0
- package/src/worlds/qq/console/events.ts +155 -0
- package/src/worlds/qq/console/gate.ts +232 -0
- package/src/worlds/qq/console/roster.ts +203 -0
- package/src/worlds/qq/console/style.css +65 -0
- package/src/worlds/qq/conversation.ts +28 -0
- package/src/worlds/qq/definition.ts +62 -0
- package/src/worlds/qq/driver.ts +375 -0
- package/src/worlds/qq/history-tools.ts +209 -0
- package/src/worlds/qq/normalize.ts +323 -0
- package/src/worlds/qq/qface-map.ts +282 -0
- package/src/worlds/qq/vision-prompt.ts +27 -0
- package/src/worlds/qq/vision.ts +642 -0
- package/src/worlds/qq/vlm.ts +142 -0
- package/src/worlds/qq/world.ts +1503 -0
- package/src/worlds/terminal/ENV_PROMPT.md +11 -0
- package/src/worlds/terminal/config.ts +9 -0
- package/src/worlds/terminal/definition.ts +14 -0
- package/src/worlds/terminal/world.ts +700 -0
- package/src/worlds/websearch/ENV_PROMPT.md +1 -0
- package/src/worlds/websearch/brave-client.ts +261 -0
- package/src/worlds/websearch/config.ts +75 -0
- package/src/worlds/websearch/definition.ts +20 -0
- package/src/worlds/websearch/world.ts +171 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按 /api/worlds 展示 active、inactive、missing 状态及声明信息。
|
|
3
|
+
* visibility 改变 agent 可见性,World 继续运行;restart 重建实例以应用构造时参数。
|
|
4
|
+
* activation 写入 worlds.<id>.enabled 并挂载或卸载。详情由各 World 的控制台页提供。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { pageIdFor } from '../../../shared/console-protocol.ts';
|
|
8
|
+
import type { ConsoleBadge, ConsoleLamp, ConsoleLink } from '../../../shared/console-protocol.ts';
|
|
9
|
+
import { get, post } from '../../core/api.ts';
|
|
10
|
+
import { PROVIDER_ROUTE } from '../../console-pages/host.ts';
|
|
11
|
+
import { resolveConsoleLinkHref } from '../../theme/handoff.ts';
|
|
12
|
+
import { icon, type ConsoleIconName } from '../../ui/icons.ts';
|
|
13
|
+
import { lampRow, paintLamps, subscribeLamps } from '../../ui/lamp.ts';
|
|
14
|
+
import { pageIntro } from '../../ui/page.ts';
|
|
15
|
+
import type { FeatureContext, FrameworkFeature } from '../feature.ts';
|
|
16
|
+
import { S } from './strings.ts';
|
|
17
|
+
|
|
18
|
+
/** World 控制台页 id 使用 world:<id>。 */
|
|
19
|
+
const WORLD_PAGE_KIND = 'world';
|
|
20
|
+
|
|
21
|
+
/** 某个 World 那一页的路由:`#/provider/<kind>:<id>`。 */
|
|
22
|
+
function worldPageId(id: string): string {
|
|
23
|
+
return pageIdFor(WORLD_PAGE_KIND, id);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 清单里的一条。字段与 `src/web/server.ts` 的 `ConsoleWorldInfo` 同形——那是三个
|
|
28
|
+
* 接口的联合,这里摊平成一个可选字段都全的形状:这一页按 `status` 分支渲染。
|
|
29
|
+
*/
|
|
30
|
+
export interface WorldView {
|
|
31
|
+
id: string;
|
|
32
|
+
status: 'active' | 'inactive' | 'missing';
|
|
33
|
+
/** World 自报的状态灯,一条链路一颗(仅 active 有意义)。 */
|
|
34
|
+
lamps?: ConsoleLamp[];
|
|
35
|
+
/** 人类可读名;没有就退回 id。 */
|
|
36
|
+
label?: string;
|
|
37
|
+
/** Persona定义的渠道;false = 部署侧选配的外挂;undefined = 没说。 */
|
|
38
|
+
declared?: boolean;
|
|
39
|
+
/** 当前对 agent 可见(仅 active 有意义)。 */
|
|
40
|
+
visible?: boolean;
|
|
41
|
+
/** 可见性已改,但当前 system 前缀还是按旧的烘出来的。 */
|
|
42
|
+
prefixDrifted?: boolean;
|
|
43
|
+
/** 装不上的原因(仅 missing)。原样显示,这一页不改写措辞。 */
|
|
44
|
+
reason?: string;
|
|
45
|
+
workspace?: string;
|
|
46
|
+
tools?: string[];
|
|
47
|
+
badges?: ConsoleBadge[];
|
|
48
|
+
links?: ConsoleLink[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function errText(err: unknown): string {
|
|
52
|
+
return err instanceof Error ? err.message : String(err);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isAbort(err: unknown): boolean {
|
|
56
|
+
return (err as { name?: unknown } | null)?.name === 'AbortError';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 渲染顺序:已挂载 → 未激活 → 未安装。同一状态内保持服务端顺序(那就是装配顺序)。
|
|
61
|
+
*/
|
|
62
|
+
function sortWorlds(worlds: readonly WorldView[]): WorldView[] {
|
|
63
|
+
const rank: Record<WorldView['status'], number> = { active: 0, inactive: 1, missing: 2 };
|
|
64
|
+
return [...worlds].sort((a, b) => (rank[a.status] ?? 9) - (rank[b.status] ?? 9));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function mountWorlds(ctx: FeatureContext): void {
|
|
68
|
+
const { ui, root } = ctx;
|
|
69
|
+
const doc = root.ownerDocument;
|
|
70
|
+
/** page id → 这张卡上那排灯的容器。轮询只碰这些节点。 */
|
|
71
|
+
const lampNodes = new Map<string, HTMLSpanElement>();
|
|
72
|
+
/** 灯的轮询只更新灯节点,不重新获取清单或重建卡片。 */
|
|
73
|
+
ctx.lifecycle.own(subscribeLamps(doc, (lamps) => {
|
|
74
|
+
for (const [id, el] of lampNodes) paintLamps(el, lamps[id] ?? []);
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
const intro = pageIntro(ui, S.introTitle);
|
|
78
|
+
const canToggleVisibility = ctx.capabilities.worldVisibility === true;
|
|
79
|
+
const canActivate = ctx.capabilities.worldActivation === true;
|
|
80
|
+
|
|
81
|
+
const sheet = ui.sheet({
|
|
82
|
+
title: S.sheetTitle,
|
|
83
|
+
en: 'active / inactive / missing',
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
const sumBar = ui.rowbar();
|
|
87
|
+
const msg = ui.msgline();
|
|
88
|
+
const reloadBtn = ui.button(S.reloadPrefixBtn, {
|
|
89
|
+
size: 'sm',
|
|
90
|
+
onClick: () => void reloadPrefix(reloadBtn),
|
|
91
|
+
});
|
|
92
|
+
sheet.body.append(sumBar, msg);
|
|
93
|
+
const grid = ui.h('div', 'iogrid');
|
|
94
|
+
root.append(intro, sheet.el, grid);
|
|
95
|
+
|
|
96
|
+
function setMsg(text: string, bad?: boolean): void {
|
|
97
|
+
msg.textContent = text;
|
|
98
|
+
msg.className = 'msgline' + (bad ? ' bad' : '');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// -------------------------------------------------------------------------
|
|
102
|
+
// 动作
|
|
103
|
+
// -------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
async function reloadPrefix(btn?: HTMLButtonElement): Promise<void> {
|
|
106
|
+
const lock = btn ? ui.disable(btn) : null;
|
|
107
|
+
try {
|
|
108
|
+
const out = await post<{ result?: string }>(
|
|
109
|
+
'/api/session/reload-prefix',
|
|
110
|
+
undefined,
|
|
111
|
+
{ signal: ctx.signal },
|
|
112
|
+
);
|
|
113
|
+
if (ctx.signal.aborted) return;
|
|
114
|
+
setMsg(out?.result || S.prefixReloaded);
|
|
115
|
+
await load();
|
|
116
|
+
} catch (err) {
|
|
117
|
+
if (isAbort(err) || ctx.signal.aborted) return;
|
|
118
|
+
setMsg(S.prefixReloadFailed(errText(err)), true);
|
|
119
|
+
} finally {
|
|
120
|
+
lock?.dispose();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 可见性只改「对 agent 是否可见」。事件投递立即生效;环境提示词与工具同属缓存前缀,
|
|
126
|
+
* 要等一次前缀重载才跟上——所以服务端报了漂移时问一句,操作者说了算。
|
|
127
|
+
*/
|
|
128
|
+
async function toggleVisibility(
|
|
129
|
+
m: WorldView,
|
|
130
|
+
wantVisible: boolean,
|
|
131
|
+
btn: HTMLButtonElement,
|
|
132
|
+
): Promise<void> {
|
|
133
|
+
const lock = ui.disable(btn);
|
|
134
|
+
let drifted = 0;
|
|
135
|
+
try {
|
|
136
|
+
const out = await post<{ result?: string; driftedWorlds?: string[] }>(
|
|
137
|
+
'/api/worlds/visibility',
|
|
138
|
+
{ id: m.id, visible: wantVisible },
|
|
139
|
+
{ signal: ctx.signal },
|
|
140
|
+
);
|
|
141
|
+
if (ctx.signal.aborted) return;
|
|
142
|
+
setMsg(out?.result || S.updated);
|
|
143
|
+
drifted = (out?.driftedWorlds ?? []).length;
|
|
144
|
+
await load();
|
|
145
|
+
} catch (err) {
|
|
146
|
+
if (isAbort(err) || ctx.signal.aborted) return;
|
|
147
|
+
setMsg(S.toggleFailed(errText(err)), true);
|
|
148
|
+
return;
|
|
149
|
+
} finally {
|
|
150
|
+
lock.dispose();
|
|
151
|
+
}
|
|
152
|
+
if (drifted === 0) return;
|
|
153
|
+
const name = m.label || m.id;
|
|
154
|
+
const ok = await ui.confirm({
|
|
155
|
+
title: S.reloadNowTitle,
|
|
156
|
+
body: S.reloadNowBody(name, wantVisible),
|
|
157
|
+
});
|
|
158
|
+
if (!ok || ctx.signal.aborted) return;
|
|
159
|
+
await reloadPrefix();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** 激活、停用与重启请求执行期间禁用相关按钮,完成后刷新清单。 */
|
|
163
|
+
async function activation(m: WorldView, wantEnabled: boolean, btn: HTMLButtonElement): Promise<void> {
|
|
164
|
+
const name = m.label || m.id;
|
|
165
|
+
if (!wantEnabled) {
|
|
166
|
+
const ok = await ui.confirm({
|
|
167
|
+
title: S.deactivateTitle(name),
|
|
168
|
+
body: S.deactivateBody(m.id),
|
|
169
|
+
danger: true,
|
|
170
|
+
});
|
|
171
|
+
if (!ok || ctx.signal.aborted) return;
|
|
172
|
+
}
|
|
173
|
+
const lock = ui.disable(btn);
|
|
174
|
+
try {
|
|
175
|
+
const out = await post<{ result?: string }>(
|
|
176
|
+
'/api/worlds/activation',
|
|
177
|
+
{ id: m.id, enabled: wantEnabled },
|
|
178
|
+
{ signal: ctx.signal },
|
|
179
|
+
);
|
|
180
|
+
if (ctx.signal.aborted) return;
|
|
181
|
+
setMsg(out?.result || (wantEnabled ? S.activated : S.deactivated));
|
|
182
|
+
void ctx.refreshNav?.().catch(ctx.onError);
|
|
183
|
+
await load();
|
|
184
|
+
} catch (err) {
|
|
185
|
+
if (isAbort(err) || ctx.signal.aborted) return;
|
|
186
|
+
setMsg(wantEnabled ? S.activateFailed(errText(err)) : S.deactivateFailed(errText(err)), true);
|
|
187
|
+
} finally {
|
|
188
|
+
lock.dispose();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function restart(m: WorldView, btn: HTMLButtonElement): Promise<void> {
|
|
193
|
+
const name = m.label || m.id;
|
|
194
|
+
const ok = await ui.confirm({
|
|
195
|
+
title: S.restartTitle(name),
|
|
196
|
+
body: S.restartBody,
|
|
197
|
+
});
|
|
198
|
+
if (!ok || ctx.signal.aborted) return;
|
|
199
|
+
const lock = ui.disable(btn);
|
|
200
|
+
try {
|
|
201
|
+
const out = await post<{ result?: string }>(
|
|
202
|
+
'/api/worlds/restart',
|
|
203
|
+
{ id: m.id },
|
|
204
|
+
{ signal: ctx.signal },
|
|
205
|
+
);
|
|
206
|
+
if (ctx.signal.aborted) return;
|
|
207
|
+
setMsg(out?.result || S.restarted);
|
|
208
|
+
await load();
|
|
209
|
+
} catch (err) {
|
|
210
|
+
if (isAbort(err) || ctx.signal.aborted) return;
|
|
211
|
+
setMsg(S.restartFailed(errText(err)), true);
|
|
212
|
+
} finally {
|
|
213
|
+
lock.dispose();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// -------------------------------------------------------------------------
|
|
218
|
+
// 渲染
|
|
219
|
+
// -------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
/** 卡角上的一颗图标键:只有图形,名字在 title / aria-label 上。 */
|
|
222
|
+
function iconButton(
|
|
223
|
+
name: ConsoleIconName,
|
|
224
|
+
label: string,
|
|
225
|
+
cls: string,
|
|
226
|
+
onClick: (btn: HTMLButtonElement) => void,
|
|
227
|
+
): HTMLButtonElement {
|
|
228
|
+
const btn = ui.h('button', `iobtn ${cls}`);
|
|
229
|
+
btn.type = 'button';
|
|
230
|
+
btn.title = label;
|
|
231
|
+
btn.setAttribute('aria-label', label);
|
|
232
|
+
btn.appendChild(icon(doc, name));
|
|
233
|
+
btn.addEventListener('click', () => onClick(btn), { signal: ctx.signal });
|
|
234
|
+
return btn;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** World 自己声明的徽标,原样摆上去,控制台不解释语义。 */
|
|
238
|
+
function badgePills(m: WorldView): HTMLSpanElement[] {
|
|
239
|
+
return (m.badges ?? []).map((b) => ui.pill(`${b.label} ${b.value}`, b.tone));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** active 状态使用 World 自报读数;其余状态显示框架提供的灰灯。 */
|
|
243
|
+
function cardLamps(m: WorldView): HTMLSpanElement {
|
|
244
|
+
const el = lampRow(doc, m.status === 'active'
|
|
245
|
+
? m.lamps ?? []
|
|
246
|
+
: [{ label: S.lampAssembly, state: 'offline', hint: m.status === 'missing' ? S.notInstalled : S.notActive }]);
|
|
247
|
+
if (m.status === 'active') lampNodes.set(worldPageId(m.id), el);
|
|
248
|
+
return el;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** 显示 Persona 声明或部署选配来源;缺失时不显示。 */
|
|
252
|
+
function declaredPills(m: WorldView): HTMLSpanElement[] {
|
|
253
|
+
if (m.declared === undefined) return [];
|
|
254
|
+
return [ui.pill(m.declared ? S.declaredByPersona : S.optionalAddon)];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** 打开 World 自己声明的外部页面。链接是 World 给的,这一页不解析它的语义。 */
|
|
258
|
+
function linkButtons(m: WorldView): HTMLButtonElement[] {
|
|
259
|
+
const view = ctx.root.ownerDocument?.defaultView ?? null;
|
|
260
|
+
const out: HTMLButtonElement[] = [];
|
|
261
|
+
for (const link of m.links ?? []) {
|
|
262
|
+
if (!link || !link.href) continue;
|
|
263
|
+
out.push(ui.button(link.label || S.open, {
|
|
264
|
+
size: 'sm',
|
|
265
|
+
variant: 'primary',
|
|
266
|
+
onClick: () => {
|
|
267
|
+
view?.open(resolveConsoleLinkHref(ctx.root.ownerDocument, link), '_blank', 'noopener');
|
|
268
|
+
},
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** 进这个 World 的详情。详情页归 World 自己那一页,这一页只是入口。 */
|
|
275
|
+
function detailButton(m: WorldView): HTMLButtonElement {
|
|
276
|
+
return ui.button(S.details, {
|
|
277
|
+
size: 'sm',
|
|
278
|
+
onClick: () => ctx.router.navigate([PROVIDER_ROUTE, worldPageId(m.id)]),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function cardShell(m: WorldView, tools: readonly string[], corner: HTMLButtonElement[]): { el: HTMLElement; body: HTMLElement } {
|
|
283
|
+
const card = ui.sheet({ title: m.label || m.id, en: S.toolsCount(m.id, tools.length) });
|
|
284
|
+
card.el.classList.add('iocard');
|
|
285
|
+
if (corner.length > 0) {
|
|
286
|
+
const box = ui.h('div', 'iocorner');
|
|
287
|
+
box.append(...corner);
|
|
288
|
+
card.el.appendChild(box);
|
|
289
|
+
}
|
|
290
|
+
return card;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** 不可用的 World 显示实际原因。 */
|
|
294
|
+
function missingCard(m: WorldView): HTMLElement {
|
|
295
|
+
const card = cardShell(m, [], []);
|
|
296
|
+
card.el.classList.add('iocard-missing');
|
|
297
|
+
const bar = ui.rowbar();
|
|
298
|
+
bar.append(cardLamps(m), ui.pill(S.notInstalled, 'off'), ...declaredPills(m));
|
|
299
|
+
card.body.appendChild(bar);
|
|
300
|
+
card.body.appendChild(ui.msgline(m.reason || S.missingReasonDefault, true));
|
|
301
|
+
return card.el;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** 未激活:角上一颗「激活」;没接激活开关时改成一句怎么手改 config 的说明。 */
|
|
305
|
+
function inactiveCard(m: WorldView): HTMLElement {
|
|
306
|
+
const corner = canActivate
|
|
307
|
+
? [iconButton('power', S.activateWorld, 'iobtn-start', (btn) => { void activation(m, true, btn); })]
|
|
308
|
+
: [];
|
|
309
|
+
const card = cardShell(m, [], corner);
|
|
310
|
+
card.el.classList.add('iocard-inactive');
|
|
311
|
+
const bar = ui.rowbar();
|
|
312
|
+
bar.append(cardLamps(m), ui.pill(S.notActive, 'off'), ...declaredPills(m));
|
|
313
|
+
card.body.appendChild(bar);
|
|
314
|
+
card.body.appendChild(ui.msgline(
|
|
315
|
+
canActivate
|
|
316
|
+
? S.inactiveNoteActivatable
|
|
317
|
+
: S.inactiveNoteManual(m.id),
|
|
318
|
+
));
|
|
319
|
+
const actions = ui.actions();
|
|
320
|
+
actions.append(detailButton(m));
|
|
321
|
+
card.body.appendChild(actions);
|
|
322
|
+
return card.el;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** 已挂载:右上角依次是可见性(热)、重启、停用。 */
|
|
326
|
+
function activeCard(m: WorldView): HTMLElement {
|
|
327
|
+
const tools = m.tools ?? [];
|
|
328
|
+
const visible = m.visible !== false;
|
|
329
|
+
const corner: HTMLButtonElement[] = [];
|
|
330
|
+
if (canToggleVisibility) {
|
|
331
|
+
corner.push(iconButton(
|
|
332
|
+
visible ? 'eye' : 'eye-off',
|
|
333
|
+
visible ? S.hideFromAgent : S.showToAgent,
|
|
334
|
+
visible ? 'iobtn-visible' : 'iobtn-hidden',
|
|
335
|
+
(btn) => { void toggleVisibility(m, !visible, btn); },
|
|
336
|
+
));
|
|
337
|
+
}
|
|
338
|
+
if (canActivate) {
|
|
339
|
+
corner.push(
|
|
340
|
+
iconButton('refresh', S.restartWorld, 'iobtn-restart', (btn) => { void restart(m, btn); }),
|
|
341
|
+
iconButton('power', S.deactivateWorld, 'iobtn-stop', (btn) => { void activation(m, false, btn); }),
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
const card = cardShell(m, tools, corner);
|
|
345
|
+
if (!visible) card.el.classList.add('iocard-hidden');
|
|
346
|
+
|
|
347
|
+
const bar = ui.rowbar();
|
|
348
|
+
bar.append(cardLamps(m), ...badgePills(m));
|
|
349
|
+
bar.append(
|
|
350
|
+
ui.pill(visible ? S.visibleToAgent : S.hidden, visible ? 'on' : 'off'),
|
|
351
|
+
...declaredPills(m),
|
|
352
|
+
);
|
|
353
|
+
if (m.prefixDrifted) bar.appendChild(ui.pill(S.prefixPending));
|
|
354
|
+
card.body.appendChild(bar);
|
|
355
|
+
|
|
356
|
+
card.body.appendChild(ui.kv([
|
|
357
|
+
{ k: S.kvTools, v: tools.join(S.listSep) || S.kvNone },
|
|
358
|
+
{ k: S.kvWorkspace, v: m.workspace || '—' },
|
|
359
|
+
]));
|
|
360
|
+
|
|
361
|
+
if (m.prefixDrifted) {
|
|
362
|
+
card.body.appendChild(ui.msgline(S.driftNote));
|
|
363
|
+
}
|
|
364
|
+
const actions = ui.actions();
|
|
365
|
+
actions.append(...linkButtons(m), detailButton(m));
|
|
366
|
+
card.body.appendChild(actions);
|
|
367
|
+
return card.el;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function worldCard(m: WorldView): HTMLElement {
|
|
371
|
+
if (m.status === 'missing') return missingCard(m);
|
|
372
|
+
if (m.status === 'inactive') return inactiveCard(m);
|
|
373
|
+
return activeCard(m);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function render(worlds: readonly WorldView[]): void {
|
|
377
|
+
sumBar.replaceChildren();
|
|
378
|
+
grid.replaceChildren();
|
|
379
|
+
lampNodes.clear();
|
|
380
|
+
|
|
381
|
+
const active = worlds.filter((m) => m.status === 'active');
|
|
382
|
+
const inactive = worlds.filter((m) => m.status === 'inactive');
|
|
383
|
+
const missing = worlds.filter((m) => m.status === 'missing');
|
|
384
|
+
const hidden = active.filter((m) => m.visible === false).length;
|
|
385
|
+
|
|
386
|
+
sumBar.appendChild(ui.pill(S.sumVisible(active.length - hidden), 'on'));
|
|
387
|
+
if (hidden > 0) sumBar.appendChild(ui.pill(S.sumHidden(hidden), 'off'));
|
|
388
|
+
if (inactive.length > 0) sumBar.appendChild(ui.pill(S.sumInactive(inactive.length), 'off'));
|
|
389
|
+
if (missing.length > 0) sumBar.appendChild(ui.pill(S.sumMissing(missing.length), 'off'));
|
|
390
|
+
sumBar.append(ui.h('span', 'grow'), reloadBtn);
|
|
391
|
+
|
|
392
|
+
if (worlds.length === 0) {
|
|
393
|
+
grid.appendChild(ui.placeholder(S.noWorlds));
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
for (const m of sortWorlds(worlds)) grid.appendChild(worldCard(m));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async function load(): Promise<void> {
|
|
400
|
+
try {
|
|
401
|
+
const data = await get<{ worlds?: WorldView[] }>('/api/worlds', { signal: ctx.signal });
|
|
402
|
+
if (ctx.signal.aborted) return;
|
|
403
|
+
render(Array.isArray(data?.worlds) ? data.worlds : []);
|
|
404
|
+
} catch (err) {
|
|
405
|
+
if (isAbort(err) || ctx.signal.aborted) return;
|
|
406
|
+
grid.replaceChildren(ui.placeholder(S.listLoadFailed(errText(err))));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
grid.appendChild(ui.placeholder(S.loading));
|
|
411
|
+
void load();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* `route` 沿用旧的 `worlds`:用户的书签与外部链接都指着它。
|
|
416
|
+
*/
|
|
417
|
+
export const worldsFeature: FrameworkFeature = {
|
|
418
|
+
route: 'world',
|
|
419
|
+
label: S.navLabel,
|
|
420
|
+
icon: 'boxes',
|
|
421
|
+
navMode: 'world-root',
|
|
422
|
+
needsAny: ['worlds'],
|
|
423
|
+
mount: mountWorlds,
|
|
424
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { pick } from '../../core/language.ts';
|
|
2
|
+
|
|
3
|
+
const zh = {
|
|
4
|
+
navLabel: 'World 总览',
|
|
5
|
+
introTitle: 'World',
|
|
6
|
+
sheetTitle: '装配状态',
|
|
7
|
+
reloadPrefixBtn: '↻ 重载系统前缀',
|
|
8
|
+
prefixReloaded: '前缀已重载',
|
|
9
|
+
prefixReloadFailed: (msg: string) => `前缀重载失败: ${msg}`,
|
|
10
|
+
updated: '已更新',
|
|
11
|
+
toggleFailed: (msg: string) => `切换失败: ${msg}`,
|
|
12
|
+
reloadNowTitle: '现在重载 system 前缀?',
|
|
13
|
+
reloadNowBody: (name: string, wantVisible: boolean) =>
|
|
14
|
+
(wantVisible ? `「${name}」已对 agent 重新可见。` : `「${name}」已对 agent 隐藏。`)
|
|
15
|
+
+ '\n\n事件投递已按新状态生效。重载会更新环境提示词与工具声明,保留已有对话。'
|
|
16
|
+
+ '取消后将在下次上下文交接或重开时更新。',
|
|
17
|
+
deactivateTitle: (name: string) => `停用「${name}」?`,
|
|
18
|
+
deactivateBody: (id: string) =>
|
|
19
|
+
'World 会立即停止(它托管的外部进程与连接一并收尾),并写回 config.json 的 '
|
|
20
|
+
+ `worlds.${id}.enabled=false。agent 的环境提示词与工具随即撤下;再次激活按当前配置重建。`,
|
|
21
|
+
activated: '已激活',
|
|
22
|
+
deactivated: '已停用',
|
|
23
|
+
activateFailed: (msg: string) => `激活失败: ${msg}`,
|
|
24
|
+
deactivateFailed: (msg: string) => `停用失败: ${msg}`,
|
|
25
|
+
restartTitle: (name: string) => `重启「${name}」?`,
|
|
26
|
+
restartBody: "停止并重建 World,应用标有「重启 World 生效」的配置。托管进程与连接会停止后重新启动。",
|
|
27
|
+
restarted: '已重启',
|
|
28
|
+
restartFailed: (msg: string) => `重启失败: ${msg}`,
|
|
29
|
+
lampAssembly: '装配',
|
|
30
|
+
notInstalled: "不可用",
|
|
31
|
+
notActive: '未激活',
|
|
32
|
+
declaredByPersona: 'Persona定义',
|
|
33
|
+
optionalAddon: '选配外挂',
|
|
34
|
+
open: '打开',
|
|
35
|
+
details: '→ 详情',
|
|
36
|
+
toolsCount: (id: string, n: number) => `${id} · ${n} 个工具`,
|
|
37
|
+
missingReasonDefault: "无法加载这个 World。",
|
|
38
|
+
activateWorld: '激活 World',
|
|
39
|
+
inactiveNoteActivatable: "激活后写入 config.json 并立即启动。",
|
|
40
|
+
inactiveNoteManual: (id: string) => `本地有实现但没装配。要启用,把 config.json 里 worlds.${id}.enabled 改为 true 后重启。`,
|
|
41
|
+
hideFromAgent: '对 agent 隐藏',
|
|
42
|
+
showToAgent: '对 agent 显示',
|
|
43
|
+
restartWorld: '重启 World',
|
|
44
|
+
deactivateWorld: '停用 World',
|
|
45
|
+
visibleToAgent: '对 agent 可见',
|
|
46
|
+
hidden: '已隐藏',
|
|
47
|
+
prefixPending: '前缀待重载',
|
|
48
|
+
kvTools: '工具',
|
|
49
|
+
kvNone: '(无)',
|
|
50
|
+
kvWorkspace: '工作区',
|
|
51
|
+
listSep: '、',
|
|
52
|
+
driftNote: '事件投递已按新状态生效;环境提示词与工具声明将在前缀重载后更新。',
|
|
53
|
+
sumVisible: (n: number) => `可见 ${n}`,
|
|
54
|
+
sumHidden: (n: number) => `已隐藏 ${n}`,
|
|
55
|
+
sumInactive: (n: number) => `未激活 ${n}`,
|
|
56
|
+
sumMissing: (n: number) => `不可用 ${n}`,
|
|
57
|
+
noWorlds: '没有任何 World',
|
|
58
|
+
listLoadFailed: (msg: string) => `World 清单加载失败: ${msg}`,
|
|
59
|
+
loading: '加载中…',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const en: typeof zh = {
|
|
63
|
+
navLabel: 'World Overview',
|
|
64
|
+
introTitle: 'Worlds',
|
|
65
|
+
sheetTitle: 'Assembly status',
|
|
66
|
+
reloadPrefixBtn: '↻ Reload system prefix',
|
|
67
|
+
prefixReloaded: 'Prefix reloaded',
|
|
68
|
+
prefixReloadFailed: (msg: string) => `Prefix reload failed: ${msg}`,
|
|
69
|
+
updated: 'Updated',
|
|
70
|
+
toggleFailed: (msg: string) => `Toggle failed: ${msg}`,
|
|
71
|
+
reloadNowTitle: 'Reload the system prefix now?',
|
|
72
|
+
reloadNowBody: (name: string, wantVisible: boolean) =>
|
|
73
|
+
(wantVisible ? `"${name}" is visible to the agent again.` : `"${name}" is now hidden from the agent.`)
|
|
74
|
+
+ '\n\nEvent delivery already follows the new state. Reloading updates the environment prompt and tool declarations and keeps existing conversation messages. '
|
|
75
|
+
+ 'If cancelled, they update at the next context handoff or restart.',
|
|
76
|
+
deactivateTitle: (name: string) => `Deactivate "${name}"?`,
|
|
77
|
+
deactivateBody: (id: string) =>
|
|
78
|
+
'The World stops immediately (its managed external processes and connections are wound down), and '
|
|
79
|
+
+ `worlds.${id}.enabled=false is written back to config.json. The agent's environment prompt and tools are withdrawn right away; activating again rebuilds it from the current config.`,
|
|
80
|
+
activated: 'Activated',
|
|
81
|
+
deactivated: 'Deactivated',
|
|
82
|
+
activateFailed: (msg: string) => `Activation failed: ${msg}`,
|
|
83
|
+
deactivateFailed: (msg: string) => `Deactivation failed: ${msg}`,
|
|
84
|
+
restartTitle: (name: string) => `Restart "${name}"?`,
|
|
85
|
+
restartBody: "Stops and rebuilds the World to apply settings marked for World restart. Managed processes and connections stop and restart.",
|
|
86
|
+
restarted: 'Restarted',
|
|
87
|
+
restartFailed: (msg: string) => `Restart failed: ${msg}`,
|
|
88
|
+
lampAssembly: 'assembly',
|
|
89
|
+
notInstalled: "Unavailable",
|
|
90
|
+
notActive: 'Inactive',
|
|
91
|
+
declaredByPersona: 'Declared by Persona',
|
|
92
|
+
optionalAddon: 'Optional add-on',
|
|
93
|
+
open: 'Open',
|
|
94
|
+
details: '→ Details',
|
|
95
|
+
toolsCount: (id: string, n: number) => `${id} · ${n} tools`,
|
|
96
|
+
missingReasonDefault: "Could not load this World.",
|
|
97
|
+
activateWorld: 'Activate World',
|
|
98
|
+
inactiveNoteActivatable: "Activation saves to config.json and starts the World immediately.",
|
|
99
|
+
inactiveNoteManual: (id: string) => `Implemented locally but not assembled. To enable it, set worlds.${id}.enabled to true in config.json and restart.`,
|
|
100
|
+
hideFromAgent: 'Hide from agent',
|
|
101
|
+
showToAgent: 'Show to agent',
|
|
102
|
+
restartWorld: 'Restart World',
|
|
103
|
+
deactivateWorld: 'Deactivate World',
|
|
104
|
+
visibleToAgent: 'Visible to agent',
|
|
105
|
+
hidden: 'Hidden',
|
|
106
|
+
prefixPending: 'Prefix reload pending',
|
|
107
|
+
kvTools: 'Tools',
|
|
108
|
+
kvNone: '(none)',
|
|
109
|
+
kvWorkspace: 'Workspace',
|
|
110
|
+
listSep: ', ',
|
|
111
|
+
driftNote: 'Event delivery already follows the new state; the environment prompt and tool declarations update after a prefix reload.',
|
|
112
|
+
sumVisible: (n: number) => `Visible ${n}`,
|
|
113
|
+
sumHidden: (n: number) => `Hidden ${n}`,
|
|
114
|
+
sumInactive: (n: number) => `Inactive ${n}`,
|
|
115
|
+
sumMissing: (n: number) => `Unavailable ${n}`,
|
|
116
|
+
noWorlds: 'No worlds',
|
|
117
|
+
listLoadFailed: (msg: string) => `Failed to load World list: ${msg}`,
|
|
118
|
+
loading: 'Loading…',
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const S = pick({ zh, en });
|