@bolloon/bolloon-agent 0.2.6 → 0.2.8
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/dist/agents/agent-manifest-protocol.js +52 -0
- package/dist/agents/chat-segmenter.js +140 -32
- package/dist/agents/peer-manifest-loader.js +210 -0
- package/dist/agents/pi-sdk.js +24 -41
- package/dist/agents/session-store.js +17 -3
- package/dist/agents/shell-guard.js +2 -2
- package/dist/agents/workflow-pivot-loop.js +12 -3
- package/dist/bootstrap/chat-archiver.js +276 -0
- package/dist/bootstrap/context-collector.js +6 -3
- package/dist/bootstrap/lifecycle-hooks.js +15 -1
- package/dist/bootstrap/memory-compressor.js +170 -0
- package/dist/bootstrap/persona-loader.js +94 -0
- package/dist/network/p2p-outbox.js +161 -0
- package/dist/network/peer-fs.js +420 -0
- package/dist/network/peer-resource-bridge.js +216 -0
- package/dist/web/client.js +29 -27
- package/dist/web/components/p2p/index.js +17 -5
- package/dist/web/components/p2p/p2p-modal.js +9 -2
- package/dist/web/server.js +666 -20
- package/dist/web/util/safe-name.js +32 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用名兜底. fallback 默认 '(未命名)'. 中文场景.
|
|
3
|
+
*/
|
|
4
|
+
export function safeChannelName(input, fallback) {
|
|
5
|
+
return safeNameInternal(input, fallback ?? '(未命名)', ['undefined', 'null', 'NaN']);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 英文场景兜底, 默认 'Unknown'.
|
|
9
|
+
*/
|
|
10
|
+
export function safePeerName(input, fallback) {
|
|
11
|
+
return safeNameInternal(input, fallback ?? 'Unknown', ['undefined', 'null', 'NaN']);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 兜底任意字段, 由 caller 指定默认 + 无效字面量集合.
|
|
15
|
+
*/
|
|
16
|
+
export function safeName(input, fallback, invalidLiterals = ['undefined', 'null', 'NaN']) {
|
|
17
|
+
return safeNameInternal(input, fallback, invalidLiterals);
|
|
18
|
+
}
|
|
19
|
+
function safeNameInternal(input, fallback, invalidLiterals) {
|
|
20
|
+
if (input === undefined || input === null)
|
|
21
|
+
return fallback;
|
|
22
|
+
if (typeof input === 'number' && Number.isNaN(input))
|
|
23
|
+
return fallback;
|
|
24
|
+
const s = String(input).trim();
|
|
25
|
+
if (!s)
|
|
26
|
+
return fallback;
|
|
27
|
+
for (const lit of invalidLiterals) {
|
|
28
|
+
if (s === lit)
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
31
|
+
return s;
|
|
32
|
+
}
|