@zhin.js/adapter-sandbox 1.1.24 → 1.1.26

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 CHANGED
@@ -1,5 +1,51 @@
1
1
  # @zhin.js/adapter-process
2
2
 
3
+ ## 1.1.26
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [cbf1fb1]
8
+ - Updated dependencies [008ccad]
9
+ - Updated dependencies [a1f1028]
10
+ - @zhin.js/client@1.1.26
11
+ - @zhin.js/console-contract@1.1.4
12
+ - @zhin.js/page@1.1.16
13
+ - @zhin.js/core@1.1.58
14
+ - @zhin.js/im-contract@1.1.13
15
+ - @zhin.js/host-http@1.1.16
16
+ - @zhin.js/adapter@1.1.30
17
+ - @zhin.js/feature-kit@1.1.14
18
+ - @zhin.js/skill@1.1.15
19
+
20
+ ## 1.1.25
21
+
22
+ ### Patch Changes
23
+
24
+ - fed2c27: Upgrade Console Host, Plugin Pages compiler/DX, and `/sandbox` workbench:
25
+
26
+ - Populate React 19, `react-dom/client`, and `react-router-dom` named exports and standalone ESM fallback in `@zhin.js/pagemanager`.
27
+ - Re-export `definePage` from `@zhin.js/page`, forward all `PageMetadata` fields (`group`, `order`, `parent`, `fullWidth`, `titleI18n`), and inject `{ pluginId, owner, localName, route, title }` props into page components.
28
+ - Add `definePluginConsoleRpc.withConfig<TConfig>()` and `@zhin.js/client` `createDeclarativePage` helper.
29
+ - Upgrade local Console shell (`page-renderer.ts`), live `log:entry` SSE broadcasts, and `/sandbox` simulated sender identity/role switching and rich segment rendering.
30
+
31
+ - ed768db: Sandbox `ready` no longer waits on a hung Docker CLI: the shell-isolation probe now has a hard 750ms deadline (SIGKILL + "timed out" status) instead of relying on execFile reporting after stdio closes.
32
+ - 74e7e87: Sandbox 工作台页面现在自带完整样式:改用 Console 主题 token(含回退值)、最小 12px 字号、手机端 44px 点按目标、暗色可用的遮罩色,移除对 Tailwind 工具类和 `adapterConsoleStyles` 的依赖,并为 Markdown 表格/代码块/列表与快捷键提示行补齐样式;表情列表加载失败与消息解析失败会以内联提示显示。本版本发布后 Console 可以删除 `agent-playground.css` 以及 `remote-entry-style-contract.ts` 中的 Sandbox 类名登记。
33
+ - Updated dependencies [6163abc]
34
+ - Updated dependencies [fed2c27]
35
+ - Updated dependencies [bc6ccb1]
36
+ - Updated dependencies [72b5a12]
37
+ - Updated dependencies [aa41889]
38
+ - Updated dependencies [4427e72]
39
+ - Updated dependencies [22bd14a]
40
+ - @zhin.js/core@1.1.57
41
+ - @zhin.js/client@1.1.25
42
+ - @zhin.js/page@1.1.15
43
+ - @zhin.js/im-contract@1.1.12
44
+ - @zhin.js/adapter@1.1.29
45
+ - @zhin.js/host-http@1.1.15
46
+ - @zhin.js/feature-kit@1.1.13
47
+ - @zhin.js/skill@1.1.14
48
+
3
49
  ## 1.1.24
4
50
 
5
51
  ### Patch Changes
package/lib/endpoint.js CHANGED
@@ -296,6 +296,8 @@ export class SandboxWsEndpoint extends SandboxClient {
296
296
  }
297
297
  const parsed = frame.message;
298
298
  void this.#emitPlatformEvent('message', raw);
299
+ const senderId = parsed.senderId || owner;
300
+ const senderName = parsed.senderName || senderId;
299
301
  const sceneId = parsed.id || owner;
300
302
  const conversation = { ...sandboxInboundConversation(String(this.#options.id), {
301
303
  type: parsed.type,
@@ -304,7 +306,7 @@ export class SandboxWsEndpoint extends SandboxClient {
304
306
  this.#logger.debug(formatCompact({
305
307
  op: 'sandbox_recv',
306
308
  target,
307
- sender: owner,
309
+ sender: senderId,
308
310
  channelType: parsed.type,
309
311
  channelId: sceneId,
310
312
  text: parsed.text.slice(0, 80),
@@ -313,9 +315,22 @@ export class SandboxWsEndpoint extends SandboxClient {
313
315
  subscription.conversation = scene;
314
316
  const messageId = parsed.messageId ?? randomUUID();
315
317
  this.#broadcast(this.#subscribers(scene, true), JSON.stringify({
316
- ...scene, conversation: scene, direction: 'inbound', senderId: owner,
318
+ ...scene, conversation: scene, direction: 'inbound', senderId,
319
+ ...(parsed.senderName ? { senderName: parsed.senderName } : {}),
320
+ ...(parsed.senderRole ? { senderRole: parsed.senderRole } : {}),
317
321
  messageId, endpoint: this.#options.defaults.id, content: parsed.content, timestamp: parsed.timestamp,
318
322
  }));
323
+ const sender = {
324
+ id: senderId,
325
+ name: senderName,
326
+ ...(parsed.senderRole
327
+ ? {
328
+ role: parsed.senderRole,
329
+ roles: parsed.senderRole === 'master' ? ['master', 'admin'] : parsed.senderRole === 'admin' ? ['admin'] : ['member'],
330
+ permissions: parsed.senderRole === 'master' ? ['master', 'admin'] : parsed.senderRole === 'admin' ? ['admin'] : [],
331
+ }
332
+ : {}),
333
+ };
319
334
  void this[endpointSpec].events.message({
320
335
  event: raw,
321
336
  ...(typeof parsed.timestamp === 'number' ? { platformSentAt: parsed.timestamp } : {}),
@@ -323,7 +338,7 @@ export class SandboxWsEndpoint extends SandboxClient {
323
338
  message: { conversation, id: messageId },
324
339
  content: parsed.text,
325
340
  segments: parsed.content,
326
- sender: { id: owner },
341
+ sender,
327
342
  endpointId: target,
328
343
  metadata: Object.freeze({
329
344
  type: parsed.type,
@@ -331,6 +346,7 @@ export class SandboxWsEndpoint extends SandboxClient {
331
346
  channelId: parsed.id || owner,
332
347
  elements: parsed.content,
333
348
  timestamp: parsed.timestamp,
349
+ ...(parsed.senderRole ? { senderRole: parsed.senderRole } : {}),
334
350
  ...(parsed.action ? { action: parsed.action } : {}),
335
351
  ...(parsed.agentRun ? { sandboxAgentRun: parsed.agentRun } : {}),
336
352
  }),
@@ -421,22 +437,34 @@ export class SandboxWsEndpoint extends SandboxClient {
421
437
  });
422
438
  }
423
439
  }
440
+ const SHELL_ISOLATION_PROBE_TIMEOUT_MS = 500;
441
+ /** Hard ceiling for the ready gate even if the Docker CLI ignores SIGTERM or a child keeps stdio open. */
442
+ const SHELL_ISOLATION_PROBE_DEADLINE_MS = 750;
424
443
  function probeShellIsolation() {
425
444
  return new Promise((resolve) => {
426
- execFile('docker', ['info', '--format', '{{.ServerVersion}}'], {
445
+ let settled = false;
446
+ const settleRef = {};
447
+ const settle = (status) => {
448
+ if (settled)
449
+ return;
450
+ settled = true;
451
+ settleRef.clear?.();
452
+ resolve(status);
453
+ };
454
+ const child = execFile('docker', ['info', '--format', '{{.ServerVersion}}'], {
427
455
  encoding: 'utf8',
428
- timeout: 500,
456
+ timeout: SHELL_ISOLATION_PROBE_TIMEOUT_MS,
429
457
  }, (error, stdout) => {
430
458
  if (!error) {
431
459
  const version = stdout.trim();
432
- resolve(Object.freeze({
460
+ settle(Object.freeze({
433
461
  available: true,
434
462
  provider: 'docker',
435
463
  message: version ? `Docker ${version}` : 'Docker ready',
436
464
  }));
437
465
  return;
438
466
  }
439
- resolve(Object.freeze({
467
+ settle(Object.freeze({
440
468
  available: false,
441
469
  provider: 'docker',
442
470
  message: error.killed || error.code === 'ETIMEDOUT'
@@ -444,6 +472,16 @@ function probeShellIsolation() {
444
472
  : 'Docker daemon is unavailable',
445
473
  }));
446
474
  });
475
+ // execFile only reports after the child's stdio closes; a hung CLI must not hold `ready` hostage.
476
+ const deadline = setTimeout(() => {
477
+ try {
478
+ child?.kill('SIGKILL');
479
+ }
480
+ catch { /* already gone */ }
481
+ settle(Object.freeze({ available: false, provider: 'docker', message: 'Docker readiness check timed out' }));
482
+ }, SHELL_ISOLATION_PROBE_DEADLINE_MS);
483
+ deadline.unref?.();
484
+ settleRef.clear = () => clearTimeout(deadline);
447
485
  }).catch(() => Object.freeze({
448
486
  available: false,
449
487
  provider: 'docker',
package/lib/protocol.d.ts CHANGED
@@ -40,6 +40,7 @@ export interface SandboxConversation {
40
40
  readonly type: 'private' | 'group' | 'channel';
41
41
  readonly id: string;
42
42
  }
43
+ export type SandboxSenderRole = 'master' | 'admin' | 'member';
43
44
  export interface SandboxParsedMessage {
44
45
  type: MessageType;
45
46
  id: string;
@@ -52,7 +53,11 @@ export interface SandboxParsedMessage {
52
53
  payload: string;
53
54
  };
54
55
  agentRun?: SandboxAgentRunConfig;
56
+ senderId?: string;
57
+ senderName?: string;
58
+ senderRole?: SandboxSenderRole;
55
59
  }
60
+ export type SandboxInboundEnvelope = SandboxParsedMessage;
56
61
  export type SandboxWsFrame = {
57
62
  readonly kind: 'subscribe';
58
63
  readonly conversation: SandboxConversation;
@@ -65,6 +70,7 @@ export type SandboxWsFrame = {
65
70
  /** Control frames never fall through into chat or platform message hooks. */
66
71
  export declare function parseSandboxWsFrame(raw: string): SandboxWsFrame;
67
72
  export declare function parseSandboxWsPayload(raw: string): SandboxParsedMessage;
73
+ export declare const parseSandboxInboundPayload: typeof parseSandboxWsPayload;
68
74
  /**
69
75
  * 入站归一化 → ConversationRef。sandbox 无平台社交图谱:
70
76
  * `private`/`group`/`channel` 直映射;`direct`(私聊)归 'private';
package/lib/protocol.js CHANGED
@@ -99,6 +99,7 @@ export function parseSandboxWsFrame(raw) {
99
99
  export function parseSandboxWsPayload(raw) {
100
100
  return normalizeSandboxWsPayload(readSandboxWirePayload(raw), raw);
101
101
  }
102
+ export const parseSandboxInboundPayload = parseSandboxWsPayload;
102
103
  function normalizeSandboxWsPayload(payload, raw) {
103
104
  const type = payload.type ?? 'private';
104
105
  const id = payload.id ?? 'sandbox-user';
@@ -135,6 +136,17 @@ function normalizeSandboxWsPayload(payload, raw) {
135
136
  const agentRun = normalizeSandboxAgentRunConfig(payload.agentRun);
136
137
  const rawMessageId = typeof payload.messageId === 'string' ? payload.messageId.trim() : '';
137
138
  const messageId = /^[A-Za-z0-9._:-]{1,160}$/u.test(rawMessageId) ? rawMessageId : undefined;
139
+ const senderId = typeof payload.senderId === 'string' && payload.senderId.trim()
140
+ ? payload.senderId.trim()
141
+ : undefined;
142
+ const senderName = typeof payload.senderName === 'string' && payload.senderName.trim()
143
+ ? payload.senderName.trim()
144
+ : undefined;
145
+ const senderRole = payload.senderRole === 'master'
146
+ || payload.senderRole === 'admin'
147
+ || payload.senderRole === 'member'
148
+ ? payload.senderRole
149
+ : undefined;
138
150
  return {
139
151
  type,
140
152
  id,
@@ -144,6 +156,9 @@ function normalizeSandboxWsPayload(payload, raw) {
144
156
  text,
145
157
  action,
146
158
  ...(agentRun ? { agentRun } : {}),
159
+ ...(senderId ? { senderId } : {}),
160
+ ...(senderName ? { senderName } : {}),
161
+ ...(senderRole ? { senderRole } : {}),
147
162
  };
148
163
  }
149
164
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-sandbox",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
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.28",
51
- "@zhin.js/client": "1.1.24",
52
- "@zhin.js/console-contract": "1.1.3",
53
- "@zhin.js/core": "1.1.56",
54
- "@zhin.js/feature-kit": "1.1.12",
55
- "@zhin.js/host-http": "1.1.14",
56
- "@zhin.js/im-contract": "1.1.11",
50
+ "@zhin.js/adapter": "1.1.30",
51
+ "@zhin.js/client": "1.1.26",
52
+ "@zhin.js/console-contract": "1.1.4",
53
+ "@zhin.js/core": "1.1.58",
54
+ "@zhin.js/feature-kit": "1.1.14",
55
+ "@zhin.js/host-http": "1.1.16",
56
+ "@zhin.js/im-contract": "1.1.13",
57
57
  "@zhin.js/logger": "1.1.2",
58
- "@zhin.js/page": "1.1.14",
59
- "@zhin.js/skill": "1.1.13"
58
+ "@zhin.js/page": "1.1.16",
59
+ "@zhin.js/skill": "1.1.15"
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.21",
68
- "@zhin.js/runtime": "1.1.18",
69
- "zhin.js": "1.1.21"
67
+ "@zhin.js/pagemanager": "1.1.23",
68
+ "@zhin.js/runtime": "1.1.20",
69
+ "zhin.js": "1.1.23"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "react": "^19.0.0",
73
- "@zhin.js/adapter": "^1.1.28",
74
- "@zhin.js/console-contract": "^1.1.3",
75
- "@zhin.js/core": "^1.1.56",
76
- "@zhin.js/host-http": "^1.1.14",
77
- "@zhin.js/page": "^1.1.14",
78
- "zhin.js": "^1.1.21"
73
+ "@zhin.js/adapter": "^1.1.30",
74
+ "@zhin.js/console-contract": "^1.1.4",
75
+ "@zhin.js/core": "^1.1.58",
76
+ "@zhin.js/host-http": "^1.1.16",
77
+ "@zhin.js/page": "^1.1.16",
78
+ "zhin.js": "^1.1.23"
79
79
  },
80
80
  "peerDependenciesMeta": {
81
81
  "react": {
@@ -22,7 +22,7 @@ export default function HtmlMessage({ html, locale = 'zh-CN' }) {
22
22
  return () => window.removeEventListener('message', onSize);
23
23
  }, [nonce]);
24
24
  const srcDoc = createHtmlMessageDocument(html, nonce);
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
+ return _jsx("iframe", { ref: frame, title: sandboxText(locale, "HTML 消息"), sandbox: "allow-scripts", srcDoc: srcDoc, className: "sandbox-html-frame", style: { height } });
26
26
  }
27
27
  /** getRandomValues is available on ordinary HTTP LAN pages as well as HTTPS. */
28
28
  export function createHtmlMessageNonce() {
@@ -28,7 +28,7 @@ export default function HtmlMessage({ html, locale = 'zh-CN' }: { readonly html:
28
28
  title={sandboxText(locale, "HTML 消息")}
29
29
  sandbox="allow-scripts"
30
30
  srcDoc={srcDoc}
31
- className="block w-full min-w-0 border-0 rounded-lg my-1 bg-transparent"
31
+ className="sandbox-html-frame"
32
32
  style={{ height }}
33
33
  />;
34
34
  }