@zhin.js/adapter-sandbox 1.1.16 → 1.1.18
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 +39 -0
- package/README.md +1 -1
- package/adapters/sandbox/index.js +2 -0
- package/adapters/sandbox/index.ts +2 -0
- package/lib/endpoint.d.ts +3 -0
- package/lib/endpoint.js +14 -4
- package/package.json +19 -19
- package/pages/index/HtmlMessage.js +3 -2
- package/pages/index/HtmlMessage.tsx +3 -2
- package/pages/index/RichTextEditor.js +4 -3
- package/pages/index/RichTextEditor.tsx +5 -3
- package/pages/index/SandboxChat.js +70 -63
- package/pages/index/SandboxChat.tsx +167 -167
- package/pages/index/agentTrace.js +74 -73
- package/pages/index/agentTrace.ts +74 -73
- package/pages/index/index.js +2 -1
- package/pages/index/index.tsx +2 -1
- package/pages/index/messages.js +227 -0
- package/pages/index/messages.ts +229 -0
- package/schema.json +35 -5
- package/src/endpoint.ts +17 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @zhin.js/adapter-process
|
|
2
2
|
|
|
3
|
+
## 1.1.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d5d7294: Console 里的 sandbox 页面改名为「试聊一下」(原「Agent 试验台」),面向普通用户(#970)。只改显示名称,路由 `/sandbox`、配置项和协议不变;导出的执行报告落款同步改名。若有脚本按旧标题 “Agent 试验台” 匹配页面,请改为 “试聊一下”,或改用路由 `/sandbox`。
|
|
8
|
+
- af29996: 为 Page 元数据增加可选 titleI18n,在页面目录、导航与 Console 客户端注册链路中保留显式标题翻译。Sandbox 页面提供英文导航标题,缺少对应语言时保留插件原题,不修改路由或访问规则。
|
|
9
|
+
- 53bc6a0: 适配器配置标签、端点命令和工具反馈支持中英文;复用当前操作语言,保持协议值、用户内容、身份、权限与发送链路不变。Sandbox 展示使用项目语言,QQ 绑定与交互状态保留完整会话身份。
|
|
10
|
+
- Updated dependencies [334e92d]
|
|
11
|
+
- Updated dependencies [f3b7c9f]
|
|
12
|
+
- Updated dependencies [658a5fb]
|
|
13
|
+
- Updated dependencies [144a17b]
|
|
14
|
+
- Updated dependencies [af29996]
|
|
15
|
+
- Updated dependencies [18296cf]
|
|
16
|
+
- Updated dependencies [08e64de]
|
|
17
|
+
- Updated dependencies [9cade30]
|
|
18
|
+
- Updated dependencies [53bc6a0]
|
|
19
|
+
- Updated dependencies [7595136]
|
|
20
|
+
- Updated dependencies [b8e594e]
|
|
21
|
+
- Updated dependencies [66b6404]
|
|
22
|
+
- Updated dependencies [adb4af2]
|
|
23
|
+
- Updated dependencies [69f9ef6]
|
|
24
|
+
- Updated dependencies [17d1301]
|
|
25
|
+
- @zhin.js/adapter@1.1.23
|
|
26
|
+
- @zhin.js/host-http@1.1.10
|
|
27
|
+
- @zhin.js/client@1.1.19
|
|
28
|
+
- @zhin.js/console-contract@1.1.3
|
|
29
|
+
- @zhin.js/page@1.1.10
|
|
30
|
+
- @zhin.js/core@1.1.51
|
|
31
|
+
- @zhin.js/skill@1.1.10
|
|
32
|
+
- @zhin.js/im-contract@1.1.7
|
|
33
|
+
- @zhin.js/feature-kit@1.1.9
|
|
34
|
+
|
|
35
|
+
## 1.1.17
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- @zhin.js/core@1.1.50
|
|
40
|
+
- @zhin.js/client@1.1.18
|
|
41
|
+
|
|
3
42
|
## 1.1.16
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ Console 沙盒页和自己写的测试客户端都用这套协议。每个 WebSo
|
|
|
111
111
|
| `text` | string | 可选。没有 `content` 时作为纯文本;`content` 里没有文本段时也用它作为消息文本 |
|
|
112
112
|
| `messageId` | string | 可选。客户端生成的消息 id,须匹配 `^[A-Za-z0-9._:-]{1,160}$`,不匹配时忽略;填写后作为这条入站消息的 id,引用回复时可据此定位 |
|
|
113
113
|
| `timestamp` | number | 可选。毫秒时间戳,默认取服务端收到的时间 |
|
|
114
|
-
| `agentRun` | object |
|
|
114
|
+
| `agentRun` | object | 可选。「试聊一下」(原 Agent 试验台)运行配置,见下表 |
|
|
115
115
|
|
|
116
116
|
- 帧内容不是 JSON 时,整段文本按一条纯文本消息处理。
|
|
117
117
|
- 消息的发送者固定为 endpoint 的 `owner`。
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { projectLocaleToken, resolveLocale } from 'zhin.js/i18n';
|
|
2
3
|
/**
|
|
3
4
|
* Convention entry: discover `adapters/sandbox/index.ts` → defineAdapter.
|
|
4
5
|
*/
|
|
@@ -19,6 +20,7 @@ export default defineAdapter({
|
|
|
19
20
|
create(context) {
|
|
20
21
|
return new SandboxWsEndpoint({
|
|
21
22
|
id: context.id,
|
|
23
|
+
locale: resolveLocale(context.use(projectLocaleToken)),
|
|
22
24
|
http: context.use(httpHostToken),
|
|
23
25
|
defaults: resolveSandboxEndpoint(context.config),
|
|
24
26
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { projectLocaleToken, resolveLocale } from 'zhin.js/i18n';
|
|
1
2
|
/**
|
|
2
3
|
* Convention entry: discover `adapters/sandbox/index.ts` → defineAdapter.
|
|
3
4
|
*/
|
|
@@ -24,6 +25,7 @@ export default defineAdapter<SandboxEndpointConfig>({
|
|
|
24
25
|
create(context) {
|
|
25
26
|
return new SandboxWsEndpoint({
|
|
26
27
|
id: context.id,
|
|
28
|
+
locale: resolveLocale(context.use(projectLocaleToken)),
|
|
27
29
|
http: context.use(httpHostToken),
|
|
28
30
|
defaults: resolveSandboxEndpoint(context.config),
|
|
29
31
|
});
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Locale } from 'zhin.js/i18n';
|
|
1
2
|
import { Endpoint, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
3
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
3
4
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -18,6 +19,8 @@ export declare function createSandboxReadinessGate(probe: ShellIsolationProbe):
|
|
|
18
19
|
afterProbe: (deliver: (status: ShellIsolationStatus) => void) => void;
|
|
19
20
|
}>;
|
|
20
21
|
export interface SandboxEndpointOptions {
|
|
22
|
+
/** Project language captured from this endpoint generation's resources. */
|
|
23
|
+
readonly locale?: Locale;
|
|
21
24
|
readonly id: CapabilityId;
|
|
22
25
|
readonly http: HttpHost;
|
|
23
26
|
readonly defaults: ResolvedSandboxBot;
|
package/lib/endpoint.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMessages, resolveLocale } from 'zhin.js/i18n';
|
|
1
2
|
import { Endpoint } from 'zhin.js/adapter';
|
|
2
3
|
/**
|
|
3
4
|
* SandboxWsEndpoint — WebSocket lifecycle and OutboundMessageService bridge for /sandbox.
|
|
@@ -64,6 +65,12 @@ export function createSandboxReadinessGate(probe) {
|
|
|
64
65
|
},
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
const messages = createMessages({
|
|
69
|
+
readOnly: { 'zh-CN': '当前连接是只读演示权限,不能运行 Agent 任务。', en: 'This connection is a read-only demo and cannot run Agent tasks.' },
|
|
70
|
+
connected: { 'zh-CN': '已连接 Sandbox「{target}」', en: 'Connected to Sandbox “{target}”' },
|
|
71
|
+
protocol: { 'zh-CN': '与 Node Host 控制台沙盒协议一致({path})', en: 'Using the Node Host Console sandbox protocol ({path})' },
|
|
72
|
+
profile: { 'zh-CN': '「试聊一下」会话已启用持久化运行配置。', en: 'The “Try a chat” session uses a persistent runtime profile.' },
|
|
73
|
+
});
|
|
67
74
|
/**
|
|
68
75
|
* Sandbox 是本地开发/测试面,无平台社交图谱(好友/群/频道),
|
|
69
76
|
* 不适用 EndpointManagement 语义端口;本 endpoint 不暴露该端口。
|
|
@@ -72,6 +79,7 @@ export class SandboxWsEndpoint extends Endpoint {
|
|
|
72
79
|
client;
|
|
73
80
|
#logger;
|
|
74
81
|
#options;
|
|
82
|
+
#locale;
|
|
75
83
|
#connections = new Map();
|
|
76
84
|
#readiness = createSandboxReadinessGate(probeShellIsolation);
|
|
77
85
|
#wsHandleRelease;
|
|
@@ -83,6 +91,7 @@ export class SandboxWsEndpoint extends Endpoint {
|
|
|
83
91
|
super();
|
|
84
92
|
this.#logger = getAdapterLogger('sandbox', options.defaults.id);
|
|
85
93
|
this.#options = options;
|
|
94
|
+
this.#locale = resolveLocale(options.locale);
|
|
86
95
|
this.client = new SandboxClient(() => this.#wsPath, () => [...this.#connections.values()].map((connection) => ({
|
|
87
96
|
target: connection.target,
|
|
88
97
|
owner: connection.owner,
|
|
@@ -221,7 +230,7 @@ export class SandboxWsEndpoint extends Endpoint {
|
|
|
221
230
|
type: 'error',
|
|
222
231
|
id: owner,
|
|
223
232
|
endpoint: target,
|
|
224
|
-
content: [{ type: 'text', data: { text:
|
|
233
|
+
content: [{ type: 'text', data: { text: messages(this.#locale, 'readOnly') } }],
|
|
225
234
|
timestamp: Date.now(),
|
|
226
235
|
}));
|
|
227
236
|
return;
|
|
@@ -293,6 +302,7 @@ export class SandboxWsEndpoint extends Endpoint {
|
|
|
293
302
|
return;
|
|
294
303
|
const readyPayload = JSON.stringify({
|
|
295
304
|
type: 'ready',
|
|
305
|
+
locale: this.#locale,
|
|
296
306
|
id: owner,
|
|
297
307
|
endpoint: target,
|
|
298
308
|
workingDirectory: process.cwd(),
|
|
@@ -302,9 +312,9 @@ export class SandboxWsEndpoint extends Endpoint {
|
|
|
302
312
|
type: 'text',
|
|
303
313
|
data: {
|
|
304
314
|
text: [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
315
|
+
messages(this.#locale, 'connected', { target }),
|
|
316
|
+
messages(this.#locale, 'protocol', { path: this.#wsPath }),
|
|
317
|
+
messages(this.#locale, 'profile'),
|
|
308
318
|
].join('\n'),
|
|
309
319
|
},
|
|
310
320
|
}],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-sandbox",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Zhin.js Sandbox adapter for Plugin Runtime (WebSocket /sandbox)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"lucide-react": "^0.525.0",
|
|
49
49
|
"react": "^19.2.8",
|
|
50
|
-
"@zhin.js/adapter": "1.1.
|
|
51
|
-
"@zhin.js/client": "1.1.
|
|
52
|
-
"@zhin.js/console-contract": "1.1.
|
|
53
|
-
"@zhin.js/core": "1.1.
|
|
54
|
-
"@zhin.js/feature-kit": "1.1.
|
|
55
|
-
"@zhin.js/host-http": "1.1.
|
|
56
|
-
"@zhin.js/im-contract": "1.1.
|
|
50
|
+
"@zhin.js/adapter": "1.1.23",
|
|
51
|
+
"@zhin.js/client": "1.1.19",
|
|
52
|
+
"@zhin.js/console-contract": "1.1.3",
|
|
53
|
+
"@zhin.js/core": "1.1.51",
|
|
54
|
+
"@zhin.js/feature-kit": "1.1.9",
|
|
55
|
+
"@zhin.js/host-http": "1.1.10",
|
|
56
|
+
"@zhin.js/im-contract": "1.1.7",
|
|
57
57
|
"@zhin.js/logger": "1.1.2",
|
|
58
|
-
"@zhin.js/page": "1.1.
|
|
59
|
-
"@zhin.js/skill": "1.1.
|
|
58
|
+
"@zhin.js/page": "1.1.10",
|
|
59
|
+
"@zhin.js/skill": "1.1.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.2.18",
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
"typescript": "^6.0.3",
|
|
65
65
|
"vitest": "^4.1.10",
|
|
66
66
|
"ws": "^8.21.1",
|
|
67
|
-
"@zhin.js/pagemanager": "1.1.
|
|
68
|
-
"@zhin.js/runtime": "1.1.
|
|
69
|
-
"zhin.js": "1.1.
|
|
67
|
+
"@zhin.js/pagemanager": "1.1.15",
|
|
68
|
+
"@zhin.js/runtime": "1.1.14",
|
|
69
|
+
"zhin.js": "1.1.16"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^19.0.0",
|
|
73
|
-
"@zhin.js/adapter": "^1.1.
|
|
74
|
-
"@zhin.js/console-contract": "^1.1.
|
|
75
|
-
"@zhin.js/core": "^1.1.
|
|
76
|
-
"@zhin.js/host-http": "^1.1.
|
|
77
|
-
"@zhin.js/page": "^1.1.
|
|
78
|
-
"zhin.js": "^1.1.
|
|
73
|
+
"@zhin.js/adapter": "^1.1.23",
|
|
74
|
+
"@zhin.js/console-contract": "^1.1.3",
|
|
75
|
+
"@zhin.js/core": "^1.1.51",
|
|
76
|
+
"@zhin.js/host-http": "^1.1.10",
|
|
77
|
+
"@zhin.js/page": "^1.1.10",
|
|
78
|
+
"zhin.js": "^1.1.16"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"react": {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { sandboxText } from './messages.js';
|
|
3
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
4
5
|
/** HTML stays in an opaque-origin frame; only the size reporter can run scripts. */
|
|
5
|
-
export default function HtmlMessage({ html }) {
|
|
6
|
+
export default function HtmlMessage({ html, locale = 'zh-CN' }) {
|
|
6
7
|
const frame = useRef(null);
|
|
7
8
|
const [nonce] = useState(createHtmlMessageNonce);
|
|
8
9
|
const [height, setHeight] = useState(240);
|
|
@@ -21,7 +22,7 @@ export default function HtmlMessage({ html }) {
|
|
|
21
22
|
return () => window.removeEventListener('message', onSize);
|
|
22
23
|
}, [nonce]);
|
|
23
24
|
const srcDoc = createHtmlMessageDocument(html, nonce);
|
|
24
|
-
return _jsx("iframe", { ref: frame, title: "HTML
|
|
25
|
+
return _jsx("iframe", { ref: frame, title: sandboxText(locale, "HTML 消息"), sandbox: "allow-scripts", srcDoc: srcDoc, className: "block w-full min-w-0 border-0 rounded-lg my-1 bg-transparent", style: { height } });
|
|
25
26
|
}
|
|
26
27
|
/** getRandomValues is available on ordinary HTTP LAN pages as well as HTTPS. */
|
|
27
28
|
export function createHtmlMessageNonce() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { sandboxText, type SandboxLocale } from './messages.js';
|
|
1
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
3
|
|
|
3
4
|
/** HTML stays in an opaque-origin frame; only the size reporter can run scripts. */
|
|
4
|
-
export default function HtmlMessage({ html }: { readonly html: string }) {
|
|
5
|
+
export default function HtmlMessage({ html, locale = 'zh-CN' }: { readonly html: string; readonly locale?: SandboxLocale }) {
|
|
5
6
|
const frame = useRef<HTMLIFrameElement>(null);
|
|
6
7
|
const [nonce] = useState(createHtmlMessageNonce);
|
|
7
8
|
const [height, setHeight] = useState(240);
|
|
@@ -24,7 +25,7 @@ export default function HtmlMessage({ html }: { readonly html: string }) {
|
|
|
24
25
|
|
|
25
26
|
return <iframe
|
|
26
27
|
ref={frame}
|
|
27
|
-
title="HTML 消息"
|
|
28
|
+
title={sandboxText(locale, "HTML 消息")}
|
|
28
29
|
sandbox="allow-scripts"
|
|
29
30
|
srcDoc={srcDoc}
|
|
30
31
|
className="block w-full min-w-0 border-0 rounded-lg my-1 bg-transparent"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { sandboxText } from './messages.js';
|
|
3
4
|
import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
-
const RichTextEditor = forwardRef(({
|
|
5
|
+
const RichTextEditor = forwardRef(({ locale = 'zh-CN', placeholder = sandboxText(locale, "输入消息..."), onSend, onChange, onAtTrigger, minHeight = '44px', maxHeight = '200px' }, ref) => {
|
|
5
6
|
const editorRef = useRef(null);
|
|
6
7
|
const atTriggerTextRef = useRef(null);
|
|
7
8
|
// 解析编辑器内容为文本和消息段
|
|
@@ -106,7 +107,7 @@ const RichTextEditor = forwardRef(({ placeholder = '输入消息...', onSend, on
|
|
|
106
107
|
span.className = 'editor-video';
|
|
107
108
|
span.dataset.url = u;
|
|
108
109
|
span.contentEditable = 'false';
|
|
109
|
-
span.textContent =
|
|
110
|
+
span.textContent = sandboxText(locale, "📹 视频");
|
|
110
111
|
insertNodeAtCursor(span);
|
|
111
112
|
handleChange();
|
|
112
113
|
};
|
|
@@ -118,7 +119,7 @@ const RichTextEditor = forwardRef(({ placeholder = '输入消息...', onSend, on
|
|
|
118
119
|
span.className = 'editor-audio';
|
|
119
120
|
span.dataset.url = u;
|
|
120
121
|
span.contentEditable = 'false';
|
|
121
|
-
span.textContent =
|
|
122
|
+
span.textContent = sandboxText(locale, "🎵 音频");
|
|
122
123
|
insertNodeAtCursor(span);
|
|
123
124
|
handleChange();
|
|
124
125
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sandboxText, type SandboxLocale } from './messages.js';
|
|
1
2
|
import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react'
|
|
2
3
|
|
|
3
4
|
export interface MessageSegment {
|
|
@@ -6,6 +7,7 @@ export interface MessageSegment {
|
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export interface RichTextEditorProps {
|
|
10
|
+
locale?: SandboxLocale
|
|
9
11
|
placeholder?: string
|
|
10
12
|
onSend?: (text: string, segments: MessageSegment[]) => void
|
|
11
13
|
onChange?: (text: string, segments: MessageSegment[]) => void
|
|
@@ -27,7 +29,7 @@ export interface RichTextEditorRef {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorProps>(
|
|
30
|
-
({
|
|
32
|
+
({ locale = 'zh-CN', placeholder = sandboxText(locale, "输入消息..."), onSend, onChange, onAtTrigger, minHeight = '44px', maxHeight = '200px' }, ref) => {
|
|
31
33
|
const editorRef = useRef<HTMLDivElement>(null)
|
|
32
34
|
const atTriggerTextRef = useRef<Text | null>(null)
|
|
33
35
|
|
|
@@ -132,7 +134,7 @@ const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorProps>(
|
|
|
132
134
|
span.className = 'editor-video'
|
|
133
135
|
span.dataset.url = u
|
|
134
136
|
span.contentEditable = 'false'
|
|
135
|
-
span.textContent =
|
|
137
|
+
span.textContent = sandboxText(locale, "📹 视频")
|
|
136
138
|
insertNodeAtCursor(span)
|
|
137
139
|
handleChange()
|
|
138
140
|
}
|
|
@@ -144,7 +146,7 @@ const RichTextEditor = forwardRef<RichTextEditorRef, RichTextEditorProps>(
|
|
|
144
146
|
span.className = 'editor-audio'
|
|
145
147
|
span.dataset.url = u
|
|
146
148
|
span.contentEditable = 'false'
|
|
147
|
-
span.textContent =
|
|
149
|
+
span.textContent = sandboxText(locale, "🎵 音频")
|
|
148
150
|
insertNodeAtCursor(span)
|
|
149
151
|
handleChange()
|
|
150
152
|
}
|