@shiju-ai/shiju-webview 0.0.0-stage → 0.5.7

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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /node_modules
2
+
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 XiangMin Liu
4
+ Copyright (c) 2025 fig2json contributors
5
+ Copyright (c) 2025 OpenClaw Team
6
+ Copyright (c) 2025 ZeroClaw Labs
7
+ Copyright (c) 2025 opencode
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,227 @@
1
- # Temporary Holding Version
1
+ # SHiJu
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ SHiJu 是一个 Rust-first 的自主代理运行时,目标是在桌面端、CLI、网关服务和长驻守护进程之间提供同一套高性能、可扩展、可审计的 Agent 能力。
4
+
5
+ 项目当前包含桌面应用、命令行入口、HTTP/WebSocket 网关、任务与记忆管理、通信通道、模型/提供商解析、ACP 桥接和跨平台 WebView helper。
6
+
7
+ ## 主要能力
8
+
9
+ - `vibewindow` CLI:交互式 Agent、单次消息、网关、守护进程、任务、记忆、技能、集成、计划任务和安全维护。
10
+ - `vibe-window` 桌面端:基于 Iced 的本地桌面应用。
11
+ - `vw-webview` helper:跨平台 WebView 窗口,用于桌面打包场景。
12
+ - `acp`:VibeWindow 作为 ACP Client 的现有桥接入口。
13
+ - `vibewindow acp`:VibeWindow 作为 ACP Agent 的 stdio 入口。
14
+ - 共享 crate:API 类型、配置类型、网关客户端、运行时核心、提供商解析和通用工具。
15
+
16
+ ## 仓库结构
17
+
18
+ ```text
19
+ crates/
20
+ vw-cli/ # vibewindow CLI 和 vibe-agent 兼容入口
21
+ vw-desktop/ # Iced 桌面应用
22
+ vw-agent/ # Agent 运行时核心
23
+ vw-acp/ # Agent Client Protocol 桥接
24
+ vw-api-types/ # API 数据结构
25
+ vw-config-types/ # 配置数据结构
26
+ vw-gateway-client/ # 网关客户端
27
+ vw-provider-resolver/ # 提供商和模型解析
28
+ vw-shared/ # 跨 crate 共享工具
29
+ vw-webview/ # WebView helper
30
+ docs/ # 使用文档、OpenAPI 和参考资料
31
+ scripts/ # 构建、安装和打包脚本
32
+ release/ # 发布说明与发布辅助文件
33
+ skills/ # 本地技能说明
34
+ ```
35
+
36
+ ## 环境要求
37
+
38
+ - Rust toolchain 使用仓库内 `rust-toolchain.toml` 指定的 `1.93.0`。
39
+ - 推荐通过 `rustup` 安装 Rust,并确保 `clippy` 组件可用。
40
+ - macOS 打包需要 `cargo-bundle`。
41
+ - Windows 交叉编译可选 `cargo-xwin`,Linux 交叉编译可选 `cross`。
42
+
43
+ ## 快速开始
44
+
45
+ 查看 CLI 帮助:
46
+
47
+ ```bash
48
+ cargo run -p vw-cli --bin shiju -- --help
49
+ ```
50
+
51
+ 启动交互式 Agent:
52
+
53
+ ```bash
54
+ cargo run -p vw-cli --bin shiju -- agent
55
+ ```
56
+
57
+ 发送单条消息:
58
+
59
+ ```bash
60
+ cargo run -p vw-cli --bin shiju -- agent -m "总结这个仓库的主要模块"
61
+ ```
62
+
63
+ 启动桌面应用:
64
+
65
+ ```bash
66
+ cargo build -p vw-webview --bin vw-webview
67
+ cargo run -p vw-desktop --bin shi-ju
68
+ ```
69
+
70
+ 启动网关:
71
+
72
+ ```bash
73
+ cargo run -p vw-cli --bin shiju -- gateway --host 127.0.0.1 --port 8080
74
+ ```
75
+
76
+ 启动长驻运行时:
77
+
78
+ ```bash
79
+ cargo run -p vw-cli --bin shiju -- daemon
80
+ ```
81
+
82
+ 作为 ACP Agent 供外部 Client 启动:
83
+
84
+ ```bash
85
+ cargo run -p vw-cli --bin shiju -- acp
86
+ ```
87
+
88
+ ## 常用 CLI 命令
89
+
90
+ ```bash
91
+ # 查看运行状态
92
+ cargo run -p vw-cli --bin shiju -- status
93
+
94
+ # 诊断模型提供商
95
+ cargo run -p vw-cli --bin shiju -- doctor models
96
+
97
+ # 导出配置 JSON Schema
98
+ cargo run -p vw-cli --bin shiju -- config schema
99
+
100
+ # 查看支持的提供商
101
+ cargo run -p vw-cli --bin shiju -- providers
102
+
103
+ # 创建项目任务
104
+ cargo run -p vw-cli --bin shiju -- task create --prompt "检查 OAuth 回调并修复"
105
+
106
+ # 读取项目任务
107
+ cargo run -p vw-cli --bin shiju -- task read --limit 20
108
+
109
+ # 查看计划任务
110
+ cargo run -p vw-cli --bin shiju -- cron list
111
+
112
+ # 生成 shell 补全
113
+ cargo run -p vw-cli --bin shiju -- completions zsh
114
+ ```
115
+
116
+ 本地安装或 release 构建后,可将上面的 `cargo run -p vw-cli --bin shiju --` 替换为 `shiju`。
117
+
118
+ ## 构建
119
+
120
+ 构建 CLI:
121
+
122
+ ```bash
123
+ cargo build -p vw-cli --bin shiju --release
124
+ ```
125
+
126
+ 构建桌面应用:
127
+
128
+ ```bash
129
+ cargo build -p vw-desktop --bin shi-ju --release
130
+ ```
131
+
132
+ 构建 WebView helper:
133
+
134
+ ```bash
135
+ cargo build -p vw-webview --bin vw-webview --release
136
+ ```
137
+
138
+ 构建 VibeWindow 作为 ACP Client 的现有桥接程序:
139
+
140
+ ```bash
141
+ cargo build -p vw-acp --bin acp --release
142
+ ```
143
+
144
+ ACP Agent 入口包含在 `vibewindow` CLI 构建中,接入配置和支持矩阵见
145
+ [`docs/vibewindow/ACP-对外接入.md`](docs/vibewindow/ACP-对外接入.md)。
146
+
147
+ ## 打包
148
+
149
+ macOS `.app` 打包:
150
+
151
+ ```bash
152
+ cargo install cargo-bundle
153
+ ./scripts/bundle_macos.sh
154
+ ```
155
+
156
+ Windows 打包:
157
+
158
+ ```bash
159
+ bash scripts/bundle_windows.sh
160
+ ```
161
+
162
+ Linux 打包:
163
+
164
+ ```bash
165
+ bash scripts/bundle_linux.sh
166
+ ```
167
+
168
+ CLI 多平台构建脚本示例:
169
+
170
+ ```bash
171
+ ./scripts/build-cli.sh --target x86_64-apple-darwin
172
+ ./scripts/build-cli.sh --target x86_64-unknown-linux-gnu --use-cross
173
+ ./scripts/build-cli.sh --target x86_64-pc-windows-msvc --use-xwin
174
+ ```
175
+
176
+ 更多平台构建说明见 [`scripts/BUILDING.md`](scripts/BUILDING.md)。
177
+
178
+ ## 配置与数据
179
+
180
+ CLI 支持通过全局参数指定配置目录:
181
+
182
+ ```bash
183
+ vibewindow --config-dir /path/to/config status
184
+ ```
185
+
186
+ 项目任务默认写入目标项目下的 `.vibewindow/tasks`。可以通过 `--project-dir` 指向其他仓库:
187
+
188
+ ```bash
189
+ vibewindow task --project-dir /path/to/repo read
190
+ ```
191
+
192
+ 完整配置键请以当前代码生成的 Schema 为准:
193
+
194
+ ```bash
195
+ vibewindow config schema > vibewindow.schema.json
196
+ ```
197
+
198
+ ## 开发检查
199
+
200
+ 基础静态检查:
201
+
202
+ ```bash
203
+ cargo clippy --all-targets --all-features -- -D warnings
204
+ ```
205
+
206
+ 按需运行更聚焦的包级检查:
207
+
208
+ ```bash
209
+ cargo clippy -p vw-cli --all-targets -- -D warnings
210
+ cargo clippy -p vw-desktop --all-targets -- -D warnings
211
+ ```
212
+
213
+ 测试命令可按变更范围选择具体 package 或测试目标运行。
214
+
215
+ ## 相关文档
216
+
217
+ - [`docs/vibewindow/ACP-对外接入.md`](docs/vibewindow/ACP-对外接入.md):ACP Agent 启动、能力矩阵与安全边界。
218
+ - [`docs/knowledge-base.md`](docs/knowledge-base.md):知识库入库、嵌入配置和验证指南。
219
+ - [`docs/vibe-agent-usage.md`](docs/vibe-agent-usage.md):Vibe Agent 使用指南。
220
+ - [`docs/openapi.json`](docs/openapi.json):网关 OpenAPI 描述。
221
+ - [`scripts/BUILDING.md`](scripts/BUILDING.md):macOS / Windows 构建与打包说明。
222
+ - [`release/README.md`](release/README.md):发布相关说明。
223
+ - [`skills/README.md`](skills/README.md):本地技能说明。
224
+
225
+ ## 许可证
226
+
227
+ 本项目使用 MIT License,见 [`LICENSE`](LICENSE)。
@@ -0,0 +1,212 @@
1
+ const { createWriteStream, existsSync, mkdirSync, mkdtemp } = require("fs");
2
+ const { join, sep } = require("path");
3
+ const { spawnSync } = require("child_process");
4
+ const { tmpdir } = require("os");
5
+
6
+ const axios = require("axios");
7
+ const rimraf = require("rimraf");
8
+ const tmpDir = tmpdir();
9
+
10
+ const error = (msg) => {
11
+ console.error(msg);
12
+ process.exit(1);
13
+ };
14
+
15
+ class Package {
16
+ constructor(platform, name, url, filename, zipExt, binaries) {
17
+ let errors = [];
18
+ if (typeof url !== "string") {
19
+ errors.push("url must be a string");
20
+ } else {
21
+ try {
22
+ new URL(url);
23
+ } catch (e) {
24
+ errors.push(e);
25
+ }
26
+ }
27
+ if (name && typeof name !== "string") {
28
+ errors.push("package name must be a string");
29
+ }
30
+ if (!name) {
31
+ errors.push("You must specify the name of your package");
32
+ }
33
+ if (binaries && typeof binaries !== "object") {
34
+ errors.push("binaries must be a string => string map");
35
+ }
36
+ if (!binaries) {
37
+ errors.push("You must specify the binaries in the package");
38
+ }
39
+
40
+ if (errors.length > 0) {
41
+ let errorMsg =
42
+ "One or more of the parameters you passed to the Binary constructor are invalid:\n";
43
+ errors.forEach((error) => {
44
+ errorMsg += error;
45
+ });
46
+ errorMsg +=
47
+ '\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
48
+ error(errorMsg);
49
+ }
50
+
51
+ this.platform = platform;
52
+ this.url = url;
53
+ this.name = name;
54
+ this.filename = filename;
55
+ this.zipExt = zipExt;
56
+ this.installDirectory = join(__dirname, "node_modules", ".bin_real");
57
+ this.binaries = binaries;
58
+
59
+ if (!existsSync(this.installDirectory)) {
60
+ mkdirSync(this.installDirectory, { recursive: true });
61
+ }
62
+ }
63
+
64
+ exists() {
65
+ for (const binaryName in this.binaries) {
66
+ const binRelPath = this.binaries[binaryName];
67
+ const binPath = join(this.installDirectory, binRelPath);
68
+ if (!existsSync(binPath)) {
69
+ return false;
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+
75
+ install(fetchOptions, suppressLogs = false) {
76
+ if (this.exists()) {
77
+ if (!suppressLogs) {
78
+ console.error(
79
+ `${this.name} is already installed, skipping installation.`,
80
+ );
81
+ }
82
+ return Promise.resolve();
83
+ }
84
+
85
+ if (existsSync(this.installDirectory)) {
86
+ rimraf.sync(this.installDirectory);
87
+ }
88
+
89
+ mkdirSync(this.installDirectory, { recursive: true });
90
+
91
+ if (!suppressLogs) {
92
+ console.error(`Downloading release from ${this.url}`);
93
+ }
94
+
95
+ return axios({ ...fetchOptions, url: this.url, responseType: "stream" })
96
+ .then((res) => {
97
+ return new Promise((resolve, reject) => {
98
+ mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
99
+ let tempFile = join(directory, this.filename);
100
+ const sink = res.data.pipe(createWriteStream(tempFile));
101
+ sink.on("error", (err) => reject(err));
102
+ sink.on("close", () => {
103
+ if (/\.tar\.*/.test(this.zipExt)) {
104
+ const result = spawnSync("tar", [
105
+ "xf",
106
+ tempFile,
107
+ // The tarballs are stored with a leading directory
108
+ // component; we strip one component in the
109
+ // shell installers too.
110
+ "--strip-components",
111
+ "1",
112
+ "-C",
113
+ this.installDirectory,
114
+ ]);
115
+ if (result.status == 0) {
116
+ resolve();
117
+ } else if (result.error) {
118
+ reject(result.error);
119
+ } else {
120
+ reject(
121
+ new Error(
122
+ `An error occurred untarring the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
123
+ ),
124
+ );
125
+ }
126
+ } else if (this.zipExt == ".zip") {
127
+ let result;
128
+ if (this.platform.artifactName.includes("windows")) {
129
+ // Windows does not have "unzip" by default on many installations, instead
130
+ // we use Expand-Archive from powershell
131
+ result = spawnSync("powershell.exe", [
132
+ "-NoProfile",
133
+ "-NonInteractive",
134
+ "-Command",
135
+ `& {
136
+ param([string]$LiteralPath, [string]$DestinationPath)
137
+ Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
138
+ }`,
139
+ tempFile,
140
+ this.installDirectory,
141
+ ]);
142
+ } else {
143
+ result = spawnSync("unzip", [
144
+ "-q",
145
+ tempFile,
146
+ "-d",
147
+ this.installDirectory,
148
+ ]);
149
+ }
150
+
151
+ if (result.status == 0) {
152
+ resolve();
153
+ } else if (result.error) {
154
+ reject(result.error);
155
+ } else {
156
+ reject(
157
+ new Error(
158
+ `An error occurred unzipping the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
159
+ ),
160
+ );
161
+ }
162
+ } else {
163
+ reject(
164
+ new Error(`Unrecognized file extension: ${this.zipExt}`),
165
+ );
166
+ }
167
+ });
168
+ });
169
+ });
170
+ })
171
+ .then(() => {
172
+ if (!suppressLogs) {
173
+ console.error(`${this.name} has been installed!`);
174
+ }
175
+ })
176
+ .catch((e) => {
177
+ error(`Error fetching release: ${e.message}`);
178
+ });
179
+ }
180
+
181
+ run(binaryName, fetchOptions) {
182
+ const promise = !this.exists()
183
+ ? this.install(fetchOptions, true)
184
+ : Promise.resolve();
185
+
186
+ promise
187
+ .then(() => {
188
+ const [, , ...args] = process.argv;
189
+
190
+ const options = { cwd: process.cwd(), stdio: "inherit" };
191
+
192
+ const binRelPath = this.binaries[binaryName];
193
+ if (!binRelPath) {
194
+ error(`${binaryName} is not a known binary in ${this.name}`);
195
+ }
196
+ const binPath = join(this.installDirectory, binRelPath);
197
+ const result = spawnSync(binPath, args, options);
198
+
199
+ if (result.error) {
200
+ error(result.error);
201
+ }
202
+
203
+ process.exit(result.status);
204
+ })
205
+ .catch((e) => {
206
+ error(e.message);
207
+ process.exit(1);
208
+ });
209
+ }
210
+ }
211
+
212
+ module.exports.Package = Package;
package/binary.js ADDED
@@ -0,0 +1,126 @@
1
+ const { Package } = require("./binary-install");
2
+ const os = require("os");
3
+ const cTable = require("console.table");
4
+ const libc = require("detect-libc");
5
+ const { configureProxy } = require("axios-proxy-builder");
6
+
7
+ const error = (msg) => {
8
+ console.error(msg);
9
+ process.exit(1);
10
+ };
11
+
12
+ const {
13
+ name,
14
+ artifactDownloadUrl,
15
+ supportedPlatforms,
16
+ glibcMinimum,
17
+ } = require("./package.json");
18
+
19
+ const builderGlibcMajorVersion = glibcMinimum.major;
20
+ const builderGlibcMInorVersion = glibcMinimum.series;
21
+
22
+ const getPlatform = () => {
23
+ const rawOsType = os.type();
24
+ const rawArchitecture = os.arch();
25
+
26
+ // We want to use rust-style target triples as the canonical key
27
+ // for a platform, so translate the "os" library's concepts into rust ones
28
+ let osType = "";
29
+ switch (rawOsType) {
30
+ case "Windows_NT":
31
+ osType = "pc-windows-msvc";
32
+ break;
33
+ case "Darwin":
34
+ osType = "apple-darwin";
35
+ break;
36
+ case "Linux":
37
+ osType = "unknown-linux-gnu";
38
+ break;
39
+ }
40
+
41
+ let arch = "";
42
+ switch (rawArchitecture) {
43
+ case "x64":
44
+ arch = "x86_64";
45
+ break;
46
+ case "arm64":
47
+ arch = "aarch64";
48
+ break;
49
+ }
50
+
51
+ if (rawOsType === "Linux") {
52
+ if (libc.familySync() == "musl") {
53
+ osType = "unknown-linux-musl-dynamic";
54
+ } else if (libc.isNonGlibcLinuxSync()) {
55
+ console.warn(
56
+ "Your libc is neither glibc nor musl; trying static musl binary instead",
57
+ );
58
+ osType = "unknown-linux-musl-static";
59
+ } else {
60
+ let libcVersion = libc.versionSync();
61
+ let splitLibcVersion = libcVersion.split(".");
62
+ let libcMajorVersion = splitLibcVersion[0];
63
+ let libcMinorVersion = splitLibcVersion[1];
64
+ if (
65
+ libcMajorVersion != builderGlibcMajorVersion ||
66
+ libcMinorVersion < builderGlibcMInorVersion
67
+ ) {
68
+ // We can't run the glibc binaries, but we can run the static musl ones
69
+ // if they exist
70
+ console.warn(
71
+ "Your glibc isn't compatible; trying static musl binary instead",
72
+ );
73
+ osType = "unknown-linux-musl-static";
74
+ }
75
+ }
76
+ }
77
+
78
+ // Assume the above succeeded and build a target triple to look things up with.
79
+ // If any of it failed, this lookup will fail and we'll handle it like normal.
80
+ let targetTriple = `${arch}-${osType}`;
81
+ let platform = supportedPlatforms[targetTriple];
82
+
83
+ if (!platform) {
84
+ error(
85
+ `Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
86
+ supportedPlatforms,
87
+ ).join(",")}`,
88
+ );
89
+ }
90
+
91
+ return platform;
92
+ };
93
+
94
+ const getPackage = () => {
95
+ const platform = getPlatform();
96
+ const url = `${artifactDownloadUrl}/${platform.artifactName}`;
97
+ let filename = platform.artifactName;
98
+ let ext = platform.zipExt;
99
+ let binary = new Package(platform, name, url, filename, ext, platform.bins);
100
+
101
+ return binary;
102
+ };
103
+
104
+ const install = (suppressLogs) => {
105
+ if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
106
+ console.warn("in demo mode, not installing binaries");
107
+ return;
108
+ }
109
+ const package = getPackage();
110
+ const proxy = configureProxy(package.url);
111
+
112
+ return package.install(proxy, suppressLogs);
113
+ };
114
+
115
+ const run = (binaryName) => {
116
+ const package = getPackage();
117
+ const proxy = configureProxy(package.url);
118
+
119
+ package.run(binaryName, proxy);
120
+ };
121
+
122
+ module.exports = {
123
+ install,
124
+ run,
125
+ getPackage,
126
+ };
package/install.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { install } = require("./binary");
4
+ install(false);