@ubean/devtools 0.6.1 → 0.6.3
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/README.md +209 -0
- package/README.zh-CN.md +209 -0
- package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-BpvIxhz4.js → browser-agent-rpc-BXhoSh1z-BTqFol0H.js} +1 -1
- package/dist/client/assets/index-CqTOBCCw.js +82 -0
- package/dist/client/index.html +2 -2
- package/dist/index.d.ts +215 -30
- package/dist/index.js +184 -227
- package/package.json +11 -10
- package/dist/client/assets/index-DJNELO3b.js +0 -82
package/dist/client/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" href="https://img.soybeanjs.dev/logo-ubean.svg?v=202608192144" type="image/svg+xml" />
|
|
7
7
|
<title>Ubean DevTools</title>
|
|
8
|
-
<script type="module" crossorigin src="
|
|
9
|
-
<link rel="stylesheet" crossorigin href="
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-CqTOBCCw.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CT-WdmcL.css">
|
|
10
10
|
</head>
|
|
11
11
|
|
|
12
12
|
<body>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
|
-
import {
|
|
2
|
+
import { DevframeDefinition } from "devframe/types";
|
|
3
3
|
import { SharedState } from "devframe/utils/shared-state";
|
|
4
|
+
import "devframe/rpc";
|
|
4
5
|
//#region src/shared/env.d.ts
|
|
5
6
|
export declare function maskSensitiveEnv(env: Record<string, string>): Record<string, string>;
|
|
6
7
|
//#endregion
|
|
@@ -238,48 +239,48 @@ export interface DevToolsInfo {
|
|
|
238
239
|
};
|
|
239
240
|
customTabs?: DevToolsCustomTab[];
|
|
240
241
|
}
|
|
241
|
-
/** Read-result shape returned by `ubean:crud
|
|
242
|
+
/** Read-result shape returned by `ubean:crud-read`. */
|
|
242
243
|
export interface CrudReadResult {
|
|
243
244
|
success: boolean;
|
|
244
245
|
content?: string;
|
|
245
246
|
data?: unknown;
|
|
246
247
|
error?: string;
|
|
247
248
|
}
|
|
248
|
-
/** Params for `ubean:ai
|
|
249
|
+
/** Params for `ubean:ai-chat`. */
|
|
249
250
|
export interface AiChatParams {
|
|
250
251
|
messages: AiChatMessage[];
|
|
251
252
|
apiKey?: string;
|
|
252
253
|
apiBase?: string;
|
|
253
254
|
model?: string;
|
|
254
255
|
}
|
|
255
|
-
declare module 'devframe' {
|
|
256
|
+
declare module 'devframe/types' {
|
|
256
257
|
interface DevframeRpcServerFunctions {
|
|
257
258
|
'ubean:get-info': () => Promise<DevToolsInfo>;
|
|
258
259
|
'ubean:get-env': () => Promise<Record<string, string>>;
|
|
259
|
-
'ubean:crud
|
|
260
|
-
'ubean:crud
|
|
261
|
-
'ubean:crud
|
|
262
|
-
'ubean:crud
|
|
263
|
-
'ubean:crud
|
|
264
|
-
'ubean:ai
|
|
265
|
-
'ubean:ai
|
|
266
|
-
'ubean:playground
|
|
267
|
-
'ubean:terminal
|
|
260
|
+
'ubean:crud-create': (params: CreateCrudParams) => Promise<CrudResult>;
|
|
261
|
+
'ubean:crud-read': (params: ReadCrudParams) => Promise<CrudReadResult>;
|
|
262
|
+
'ubean:crud-update': (params: UpdateCrudParams) => Promise<CrudResult>;
|
|
263
|
+
'ubean:crud-delete': (params: DeleteCrudParams) => Promise<CrudResult>;
|
|
264
|
+
'ubean:crud-restore': (path: string) => Promise<CrudResult>;
|
|
265
|
+
'ubean:ai-tools': () => Promise<AiToolDefinition[]>;
|
|
266
|
+
'ubean:ai-chat': (params: AiChatParams) => Promise<AiChatResponse>;
|
|
267
|
+
'ubean:playground-invoke': (params: PlaygroundInvokeParams) => Promise<PlaygroundInvokeResult>;
|
|
268
|
+
'ubean:terminal-start': (params: TerminalStartParams) => Promise<{
|
|
268
269
|
sessionId: string;
|
|
269
270
|
}>;
|
|
270
|
-
'ubean:terminal
|
|
271
|
+
'ubean:terminal-input': (params: {
|
|
271
272
|
sessionId: string;
|
|
272
273
|
data: string;
|
|
273
274
|
}) => Promise<boolean>;
|
|
274
|
-
'ubean:terminal
|
|
275
|
+
'ubean:terminal-resize': (params: {
|
|
275
276
|
sessionId: string;
|
|
276
277
|
cols: number;
|
|
277
278
|
rows: number;
|
|
278
279
|
}) => Promise<boolean>;
|
|
279
|
-
'ubean:terminal
|
|
280
|
+
'ubean:terminal-poll': (params: {
|
|
280
281
|
sessionId: string;
|
|
281
282
|
}) => Promise<TerminalPollResult>;
|
|
282
|
-
'ubean:terminal
|
|
283
|
+
'ubean:terminal-kill': (params: {
|
|
283
284
|
sessionId: string;
|
|
284
285
|
}) => Promise<boolean>;
|
|
285
286
|
}
|
|
@@ -465,6 +466,41 @@ export declare function buildDevToolsInfo(opts: BuildInfoOptions): DevToolsInfo;
|
|
|
465
466
|
/** Initial empty state (used before scan data arrives). */
|
|
466
467
|
export declare function emptyDevToolsInfo(startTime: number): DevToolsInfo;
|
|
467
468
|
//#endregion
|
|
469
|
+
//#region src/node/rpc/types.d.ts
|
|
470
|
+
/**
|
|
471
|
+
* 本包 RPC 的命名空间。所有裸名注册后成为 `<UBEAN_RPC_NAMESPACE>:<bare-name>`。
|
|
472
|
+
*/
|
|
473
|
+
export declare const UBEAN_RPC_NAMESPACE = "ubean";
|
|
474
|
+
/**
|
|
475
|
+
* `ubean:ai:stream` —— AI 流式响应的 shared state key。
|
|
476
|
+
*
|
|
477
|
+
* **不是** scoped key:`ctx.scope('ubean').rpc.sharedState.get('ai:stream')` 会再加一层前缀
|
|
478
|
+
* (`ubean:ai:stream` 本身已含 `:`,`qualifyName` 原样返回,因此两种写法恰好都落到这个 key)。
|
|
479
|
+
* 这里显式写全名,避免读者以为它经过 scope。
|
|
480
|
+
*/
|
|
481
|
+
export declare const UBEAN_AI_STREAM_STATE_KEY = "ubean:ai:stream";
|
|
482
|
+
/**
|
|
483
|
+
* anchor dock 的共享 iframe 配置。
|
|
484
|
+
*
|
|
485
|
+
* `frameId` / `subTabs` 属于 **`DevframeViewIframe`**(不是 `DevframeDockDefaults`),
|
|
486
|
+
* 因此不能写在 `DevframeDefinition.dock` 里 —— 它们必须经
|
|
487
|
+
* `initHub({ devframes: [{ devframe, dock }] })`(或 `ctx.install(def, { dock })`)传入。
|
|
488
|
+
* 这里集中一处,CLI 与测试都从这里取。
|
|
489
|
+
*
|
|
490
|
+
* - `frameId`:所有视图 dock 共用一个 iframe 元素(软导航池)。
|
|
491
|
+
* - `subTabs`:客户端 host 自动挂 frame-nav 适配器,运行时发现视图清单。
|
|
492
|
+
*
|
|
493
|
+
* **不要设 `visibility: 'false'`**:它会隐藏 anchor 自己的 dock 按钮,而 iframe 只在 anchor
|
|
494
|
+
* 被激活时才挂载 —— 隐藏 anchor 就永远发现不了视图清单,外壳里只剩一个空的 dock 侧栏
|
|
495
|
+
* (实测 2026-10-11:面板整个打不开)。
|
|
496
|
+
*/
|
|
497
|
+
export declare const UBEAN_ANCHOR_DOCK: {
|
|
498
|
+
readonly frameId: "ubean";
|
|
499
|
+
readonly subTabs: {
|
|
500
|
+
readonly protocol: "postmessage";
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
//#endregion
|
|
468
504
|
//#region src/node/index.d.ts
|
|
469
505
|
/**
|
|
470
506
|
* Options injected by the ubean dev runner so the DevTools plugin can reach
|
|
@@ -511,16 +547,38 @@ interface UbeanDevtoolsPluginOptions {
|
|
|
511
547
|
* via sharedState — replacing the old 3s polling pattern.
|
|
512
548
|
*/
|
|
513
549
|
registerRefresh?: (fn: () => void) => void;
|
|
550
|
+
/**
|
|
551
|
+
* Mount base for the DevTools SPA. Defaults to `/_devtools/`.
|
|
552
|
+
*
|
|
553
|
+
* devframe 的约定是每个 devframe 挂在 hub base 的 `<id>/` 下;ubean 保留
|
|
554
|
+
* `/_devtools/` 作为**用户可见**的路径(CLI banner、文档、`devtools` 命令都印它),
|
|
555
|
+
* 与 Vite 自己的 `/__devtools/` 外壳互不干扰。SPA 产物必须用相对 base 构建
|
|
556
|
+
* (见 `client/vite.config.ts` 的 `base: './'`),否则换前缀就白屏。
|
|
557
|
+
*/
|
|
558
|
+
basePath?: string;
|
|
514
559
|
}
|
|
515
560
|
/**
|
|
516
|
-
*
|
|
561
|
+
* 构建 `@ubean/devtools` 的 devframe 定义。
|
|
517
562
|
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
563
|
+
* 与旧 DTK 接线的区别:
|
|
564
|
+
* - 不再手动 `ctx.views.hostStatic` / 手写 11 个 dock entry —— hub 的 `ctx.install()`
|
|
565
|
+
* 负责服务 SPA、注册 anchor dock 与 `__connection.json`;
|
|
566
|
+
* - 不再有那段 `__connection.json` 转发 hack(hub 的 `mountConnectionMeta` 原生支持);
|
|
567
|
+
* - RPC 走 `ctx.scope('ubean')`,裸名注册(`get-info` → wire 名 `ubean:get-info`)。
|
|
522
568
|
*/
|
|
523
|
-
export declare function
|
|
569
|
+
export declare function createUbeanDevframe(options: UbeanDevtoolsPluginOptions): DevframeDefinition;
|
|
570
|
+
/**
|
|
571
|
+
* Ubean DevTools 的 Vite 插件 —— `createUbeanDevframe()` 的装配壳。
|
|
572
|
+
*
|
|
573
|
+
* 插件本身**不挂 hub**:hub 由 `@devframes/vite/hub` 的 `viteDevframeHub()` 在 dev server
|
|
574
|
+
* 里挂载,本插件只是把 devframe 定义交给它(`devframes: [createUbeanDevframe(...)]`)。
|
|
575
|
+
* 因此这个函数返回的 `Plugin` 仅用于携带 `__ubeanDevframe` 标记,便于 CLI 组装。
|
|
576
|
+
*/
|
|
577
|
+
interface UbeanDevtoolsPlugin extends Plugin {
|
|
578
|
+
/** 供 CLI 取出定义并挂到 hub 上。 */
|
|
579
|
+
readonly __ubeanDevframe: DevframeDefinition;
|
|
580
|
+
}
|
|
581
|
+
export declare function ubeanDevtoolsPlugin(options: UbeanDevtoolsPluginOptions): UbeanDevtoolsPlugin;
|
|
524
582
|
//#endregion
|
|
525
583
|
//#region src/node/rpc/index.d.ts
|
|
526
584
|
interface RpcDeps {
|
|
@@ -534,13 +592,140 @@ interface RpcDeps {
|
|
|
534
592
|
} | undefined;
|
|
535
593
|
}
|
|
536
594
|
/**
|
|
537
|
-
*
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
595
|
+
* 全部 RPC 定义(裸名)。`setup` 里逐个 `ctx.scope('ubean').rpc.register(fn)`。
|
|
596
|
+
*/
|
|
597
|
+
export declare function createAllRpcFunctions(deps: RpcDeps): ({
|
|
598
|
+
readonly name: "get-info";
|
|
599
|
+
readonly type: "query";
|
|
600
|
+
readonly setup: () => {
|
|
601
|
+
handler: () => import("devframe/utils/shared-state").ImmutableObject<DevToolsInfo>;
|
|
602
|
+
};
|
|
603
|
+
} | {
|
|
604
|
+
readonly name: "get-env";
|
|
605
|
+
readonly type: "query";
|
|
606
|
+
readonly setup: () => {
|
|
607
|
+
handler: () => Record<string, string>;
|
|
608
|
+
};
|
|
609
|
+
} | {
|
|
610
|
+
readonly name: "crud-create";
|
|
611
|
+
readonly type: "action";
|
|
612
|
+
readonly setup: () => {
|
|
613
|
+
handler: (params: CreateCrudParams) => Promise<CrudResult>;
|
|
614
|
+
};
|
|
615
|
+
} | {
|
|
616
|
+
readonly name: "crud-read";
|
|
617
|
+
readonly type: "query";
|
|
618
|
+
readonly setup: () => {
|
|
619
|
+
handler: (params: ReadCrudParams) => Promise<{
|
|
620
|
+
success: boolean;
|
|
621
|
+
content?: string;
|
|
622
|
+
data?: unknown;
|
|
623
|
+
error?: string;
|
|
624
|
+
}>;
|
|
625
|
+
};
|
|
626
|
+
} | {
|
|
627
|
+
readonly name: "crud-update";
|
|
628
|
+
readonly type: "action";
|
|
629
|
+
readonly setup: () => {
|
|
630
|
+
handler: (params: UpdateCrudParams) => Promise<CrudResult>;
|
|
631
|
+
};
|
|
632
|
+
} | {
|
|
633
|
+
readonly name: "crud-delete";
|
|
634
|
+
readonly type: "action";
|
|
635
|
+
readonly setup: () => {
|
|
636
|
+
handler: (params: DeleteCrudParams) => Promise<CrudResult>;
|
|
637
|
+
};
|
|
638
|
+
} | {
|
|
639
|
+
readonly name: "crud-restore";
|
|
640
|
+
readonly type: "action";
|
|
641
|
+
readonly setup: () => {
|
|
642
|
+
handler: (path: string) => Promise<CrudResult>;
|
|
643
|
+
};
|
|
644
|
+
} | {
|
|
645
|
+
readonly name: "ai-tools";
|
|
646
|
+
readonly type: "query";
|
|
647
|
+
readonly setup: () => {
|
|
648
|
+
handler: () => AiToolDefinition[];
|
|
649
|
+
};
|
|
650
|
+
} | {
|
|
651
|
+
readonly name: "ai-chat";
|
|
652
|
+
readonly type: "action";
|
|
653
|
+
readonly setup: () => {
|
|
654
|
+
handler: (params: {
|
|
655
|
+
messages: AiChatMessage[];
|
|
656
|
+
apiKey?: string;
|
|
657
|
+
apiBase?: string;
|
|
658
|
+
model?: string;
|
|
659
|
+
}) => Promise<AiChatResponse>;
|
|
660
|
+
};
|
|
661
|
+
} | {
|
|
662
|
+
readonly name: "ai-chat-stream";
|
|
663
|
+
readonly type: "action";
|
|
664
|
+
readonly setup: () => {
|
|
665
|
+
handler: (params: {
|
|
666
|
+
messages: AiChatMessage[];
|
|
667
|
+
requestId: string;
|
|
668
|
+
apiKey?: string;
|
|
669
|
+
apiBase?: string;
|
|
670
|
+
model?: string;
|
|
671
|
+
}) => Promise<AiChatResponse>;
|
|
672
|
+
};
|
|
673
|
+
} | {
|
|
674
|
+
readonly name: "playground-invoke";
|
|
675
|
+
readonly type: "action";
|
|
676
|
+
readonly setup: () => {
|
|
677
|
+
handler: (params: PlaygroundInvokeParams) => Promise<PlaygroundInvokeResult>;
|
|
678
|
+
};
|
|
679
|
+
} | {
|
|
680
|
+
readonly name: "terminal-start";
|
|
681
|
+
readonly type: "action";
|
|
682
|
+
readonly setup: () => {
|
|
683
|
+
handler: (params: TerminalStartParams) => Promise<{
|
|
684
|
+
sessionId: string;
|
|
685
|
+
}>;
|
|
686
|
+
};
|
|
687
|
+
} | {
|
|
688
|
+
readonly name: "terminal-input";
|
|
689
|
+
readonly type: "action";
|
|
690
|
+
readonly setup: () => {
|
|
691
|
+
handler: (params: {
|
|
692
|
+
sessionId: string;
|
|
693
|
+
data: string;
|
|
694
|
+
}) => Promise<boolean>;
|
|
695
|
+
};
|
|
696
|
+
} | {
|
|
697
|
+
readonly name: "terminal-resize";
|
|
698
|
+
readonly type: "action";
|
|
699
|
+
readonly setup: () => {
|
|
700
|
+
handler: (params: {
|
|
701
|
+
sessionId: string;
|
|
702
|
+
cols: number;
|
|
703
|
+
rows: number;
|
|
704
|
+
}) => Promise<boolean>;
|
|
705
|
+
};
|
|
706
|
+
} | {
|
|
707
|
+
readonly name: "terminal-poll";
|
|
708
|
+
readonly type: "query";
|
|
709
|
+
readonly setup: () => {
|
|
710
|
+
handler: (params: {
|
|
711
|
+
sessionId: string;
|
|
712
|
+
}) => Promise<TerminalPollResult>;
|
|
713
|
+
};
|
|
714
|
+
} | {
|
|
715
|
+
readonly name: "terminal-kill";
|
|
716
|
+
readonly type: "action";
|
|
717
|
+
readonly setup: () => {
|
|
718
|
+
handler: (params: {
|
|
719
|
+
sessionId: string;
|
|
720
|
+
}) => Promise<boolean>;
|
|
721
|
+
};
|
|
722
|
+
})[];
|
|
723
|
+
/**
|
|
724
|
+
* 全部 RPC 定义的元组类型(每个子模块返回 `as const` 元组,故这里是精确的窄元组)。
|
|
725
|
+
* 客户端侧的 wire 签名由 `RpcDefinitionsToFunctionsWithNamespace<'ubean', UbeanRpcFunctions>`
|
|
726
|
+
* 推导。
|
|
542
727
|
*/
|
|
543
|
-
|
|
728
|
+
type UbeanRpcFunctions = ReturnType<typeof createAllRpcFunctions>;
|
|
544
729
|
//#endregion
|
|
545
730
|
//#region src/define-tab.d.ts
|
|
546
731
|
/**
|
|
@@ -561,4 +746,4 @@ export declare function defineDevToolsTab(tab: DevToolsTabDefinition): DevToolsT
|
|
|
561
746
|
export declare function getCustomTabs(): DevToolsTabDefinition[];
|
|
562
747
|
export declare function clearCustomTabs(): void;
|
|
563
748
|
//#endregion
|
|
564
|
-
export {
|
|
749
|
+
export type { AiChatMessage, AiChatResponse, AiToolDefinition, DevToolsAiServer, DevToolsConfigMeta, DevToolsCrudServer, DevToolsHooks, DevToolsHooksInstance, DevToolsTabDefinition, RpcDeps, ScanResultLike, TerminalPollResult, TerminalServer, TerminalStartParams, UbeanDevtoolsPlugin, UbeanDevtoolsPluginOptions, UbeanRpcFunctions };
|