Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3caebfd8a | ||
|
|
1eeb288143 | ||
|
|
4272dd8e60 | ||
|
|
7666db9f1d | ||
|
|
f9de8337b2 | ||
|
|
4beafe40cc | ||
|
|
3710f50ea4 |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hose-use",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。",
|
||||
"author": {
|
||||
"name": "yingqing"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# hose-use (v0.9.3)
|
||||
# hose-use (v0.9.5)
|
||||
|
||||
合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。
|
||||
|
||||
@@ -55,7 +55,7 @@ hose-use version
|
||||
| `HOSE_AIPRO_LICENSE_FILE` | AI PRO 凭证文件路径(默认 `~/.config/hose-use/aipro-license.token`,0600) |
|
||||
| `HOSE_AIPRO_LICENSE_PRIVATE_KEY` / `HOSE_AIPRO_LICENSE_PRIVATE_FILE` | 仅签发方使用,客户端运行不需要 |
|
||||
|
||||
AI PRO 常驻服务启动后,浏览器打开 `http://127.0.0.1:8889/report` 即为本地 Web 控制台(Vue 单页、资源全内嵌、不依赖 CDN)。前端源码在 `web/`,构建产物由 `bun run web:build` 生成并内嵌进二进制。
|
||||
AI PRO 常驻服务启动后,浏览器打开 `http://127.0.0.1:8889/report` 即为本地 Web 控制台(Vue 单页、资源全内嵌、不依赖 CDN)。前端源码在 `web/`,构建产物由 `bun run web:build` 生成并内嵌进二进制。`GET /docs` 的交互式 API 文档同样全离线——Scalar 运行时由 `GET /static/scalar.js` 本地提供,仅在升级版本时才需要 `bun run docs:fetch` 联网刷新。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hose-use",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"module": "src/server.ts",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
@@ -29,6 +29,7 @@
|
||||
"openapi:bundle": "bun run scripts/generate/bundle-openapi.ts",
|
||||
"openapi:generate-raw": "bun run scripts/generate/generate-raw-openapi.ts",
|
||||
"openapi:all": "bun run scripts/generate/generate-raw-openapi.ts && bun run scripts/generate/bundle-openapi.ts",
|
||||
"docs:fetch": "node scripts/build/build-docs.mjs",
|
||||
"web:dev": "bun --cwd web run dev",
|
||||
"web:build": "node scripts/build/build-webui.mjs",
|
||||
"build:binary": "node scripts/build/build-binary.mjs",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
| `build-plugin.mjs` | 打包 `dist/mcp/server.js`(MCP 单文件产物) |
|
||||
| `package-plugin.mjs` | 生成 `dist/bin/hose-use-plugin-v<版本>.tar.gz` 完整插件包 |
|
||||
| `build-webui.mjs` | 构建 `web/` 的 Vue 控制台,把 JS/CSS 内联成 `src/packaging/generated/webui.txt` 供二进制内嵌 |
|
||||
| `build-docs.mjs` | 拉取固定版本 Scalar standalone 并校验 SHA-256,生成 `src/packaging/generated/scalar-standalone.js.txt` |
|
||||
|
||||
`build-webui.mjs` 需要开发机先执行 `bun install --cwd web`;生成物随 git 提交,CI 与编译二进制不需要前端依赖。其余三个脚本只依赖根仓库的 `bun install`。
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 刷新 /docs 页面使用的 Scalar 浏览器运行时。
|
||||
*
|
||||
* 固定版本 + SHA-256 校验,产物写到 src/packaging/generated/ 并随 git 提交,
|
||||
* 因此运行时完全离线,编译二进制与 CI 都不需要访问 CDN。
|
||||
* 用法:bun run docs:fetch(仅在升级 Scalar 版本时需要)
|
||||
*/
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
|
||||
const SCALAR_VERSION = "1.25.101";
|
||||
const SOURCE = `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${SCALAR_VERSION}/dist/browser/standalone.js`;
|
||||
const EXPECTED_SHA256 = "045c6a1ffa88167ea7f8adb8359cdfe2d2233faead3ebe1d2ec0b1e7975d3fdc";
|
||||
|
||||
const root = resolve(import.meta.dirname, "../..");
|
||||
const target = join(root, "src", "packaging", "generated", "scalar-standalone.js.txt");
|
||||
|
||||
console.log(`[build:docs] fetching @scalar/api-reference@${SCALAR_VERSION} ...`);
|
||||
const response = await fetch(SOURCE);
|
||||
if (!response.ok) {
|
||||
console.error(`[build:docs] 下载失败: HTTP ${response.status}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const bytes = Buffer.from(await response.arrayBuffer());
|
||||
const actual = createHash("sha256").update(bytes).digest("hex");
|
||||
if (actual !== EXPECTED_SHA256) {
|
||||
console.error(`[build:docs] SHA-256 不匹配,拒绝写入`);
|
||||
console.error(` expected=${EXPECTED_SHA256}`);
|
||||
console.error(` actual =${actual}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 后缀 .txt:Bun 对 .js 的 text import 可能被当成模块;内容仍是完整 JS。
|
||||
mkdirSync(dirname(target), { recursive: true });
|
||||
writeFileSync(target, bytes);
|
||||
console.log(`[build:docs] ✓ ${target} (${(bytes.length / 1024 / 1024).toFixed(2)} MiB, sha256 ${actual.slice(0, 12)}…)`);
|
||||
@@ -2,11 +2,11 @@
|
||||
name: hose-aipro
|
||||
description: "合思 AI PRO(EASO AI PRO)确定性审批仲裁网关 CLI 与技能套件:单据挂载绑定、事实证据核验与打标 (PASS/FAIL/SKIP)、审核要点/规则场景库检索、确定性审批仲裁(同意/驳回/转人工硬阻断)、审计轨迹日志查询与常驻服务管理。用于一切合思 AI PRO 确定性审批仲裁与要点核验请求。"
|
||||
metadata:
|
||||
version: 0.9.3
|
||||
version: 0.9.5
|
||||
short-description: 合思 AI PRO 确定性审批仲裁网关与审核要点核验 skill
|
||||
---
|
||||
|
||||
# hose-aipro (v0.9.3)
|
||||
# hose-aipro (v0.9.5)
|
||||
|
||||
合思 AI PRO 确定性审批仲裁网关是专门面向企业财务核算、单据审核与自动化合规风控的确定性仲裁命令行与 SDK。
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
name: hose-use
|
||||
description: "合思/易快报(Ekuaibao)企业级 SaaS 一站式能力:hose-use CLI/SDK 多账号登录、租户切换、单据检索与审批动作、自建应用与工作流扫描、密钥与应用中心、常驻守护进程与 HTTP 文档/OpenAPI,以及工作流 MVEL 代码节点脚本生成调试、节点批量开通。用于一切合思/易快报相关请求。"
|
||||
metadata:
|
||||
version: 0.9.3
|
||||
version: 0.9.5
|
||||
short-description: 合思/易快报 企业级 CLI 与工作流 skill 套件(含 MVEL 代码节点)
|
||||
---
|
||||
|
||||
# hose-use (v0.9.3)
|
||||
# hose-use (v0.9.5)
|
||||
|
||||
在具备 MCP 的 AI 智能体环境中,**优先使用 `hose_cli` 单工具网关**,传入 `command: string` 执行;在终端或自动化脚本中,直接调用全局 `hose` 或 `hose-use` 命令行。
|
||||
本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
openapi: 3.1.0
|
||||
info:
|
||||
title: hose-use API & MCP Tools Specification
|
||||
version: 0.9.3
|
||||
version: 0.9.5
|
||||
description: >-
|
||||
Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows.
|
||||
servers:
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "hose-use API & MCP Tools Specification",
|
||||
"version": "0.9.3",
|
||||
"version": "0.9.5",
|
||||
"description": "Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows."
|
||||
},
|
||||
"servers": [
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { renderDocsHtml } from "./docs.js";
|
||||
import { handleHttpRequest } from "./routes.js";
|
||||
import { getScalarStandaloneJs } from "../packaging/embedded-docs.js";
|
||||
|
||||
describe("离线 API 文档", () => {
|
||||
test("HTML 不引用任何 CDN,指向本地路由", () => {
|
||||
const html = renderDocsHtml();
|
||||
expect(html).toContain('src="/static/scalar.js"');
|
||||
expect(html).toContain('data-url="/openapi.json"');
|
||||
expect(html).toContain('id="api-reference"');
|
||||
expect(html).not.toContain("cdn.jsdelivr.net");
|
||||
expect(html).not.toMatch(/src="https?:\/\//);
|
||||
expect(html).toContain("connect-src 'self'");
|
||||
expect(html).toContain("Content-Security-Policy");
|
||||
});
|
||||
|
||||
test("内嵌运行时是完整的 Scalar standalone", () => {
|
||||
const js = getScalarStandaloneJs();
|
||||
expect(js.length).toBeGreaterThan(1_000_000);
|
||||
expect(js).toContain("Scalar");
|
||||
expect(js).not.toContain("</script>");
|
||||
});
|
||||
|
||||
test("GET /static/scalar.js 返回 JS 且与内嵌产物一致", async () => {
|
||||
let status = 0;
|
||||
let headers: Record<string, string> = {};
|
||||
let body = "";
|
||||
const res = {
|
||||
setHeader: (key: string, value: unknown) => { headers[key] = String(value); },
|
||||
writeHead: (code: number, next: Record<string, string>) => {
|
||||
status = code;
|
||||
headers = { ...headers, ...next };
|
||||
},
|
||||
end: (value?: string) => { body = value ?? ""; },
|
||||
headersSent: false,
|
||||
};
|
||||
|
||||
await handleHttpRequest(
|
||||
{ method: "GET", url: "/static/scalar.js", headers: { host: "localhost" } } as never,
|
||||
res as never,
|
||||
{ app: "hose-use" }
|
||||
);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(headers["Content-Type"]).toContain("application/javascript");
|
||||
expect(body).toBe(getScalarStandaloneJs());
|
||||
});
|
||||
});
|
||||
+3
-1
@@ -6,6 +6,8 @@ export function renderDocsHtml(): string {
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<!-- 运行时全部资源来自本地:即使 Scalar 内置的"示例规范"分支被触发也发不出外网请求 -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; worker-src 'self' blob:;" />
|
||||
<title>hose-use API Reference (v${VERSION})</title>
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚡</text></svg>" />
|
||||
<style>
|
||||
@@ -22,7 +24,7 @@ export function renderDocsHtml(): string {
|
||||
id="api-reference"
|
||||
data-url="/openapi.json"
|
||||
data-configuration='{"theme":"purple","layout":"modern","showSidebar":true}'
|
||||
src="https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.101/dist/browser/standalone.js"
|
||||
src="/static/scalar.js"
|
||||
></script>
|
||||
</body>
|
||||
</html>`;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { runAiProCli } from "../aipro-cli.js";
|
||||
import { loadCorpConfigs, loadGlobalConfig } from "../core/config/loader.js";
|
||||
import { getOpenApiSchema } from "../packaging/embedded-openapi.js";
|
||||
import { getAiProWebUiHtml } from "../packaging/embedded-webui.js";
|
||||
import { getScalarStandaloneJs } from "../packaging/embedded-docs.js";
|
||||
import { tokenizeCommand, normalizeCliArgs } from "../server.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import { renderDocsHtml } from "./docs.js";
|
||||
@@ -125,6 +126,12 @@ export async function handleHttpRequest(
|
||||
return;
|
||||
}
|
||||
|
||||
// /docs 的 Scalar 运行时由本地提供,彻底去掉 CDN 依赖
|
||||
if (method === "GET" && pathname === "/static/scalar.js") {
|
||||
sendJavascript(res, 200, getScalarStandaloneJs());
|
||||
return;
|
||||
}
|
||||
|
||||
if (method === "GET" && pathname === "/docs") {
|
||||
sendHtml(res, 200, renderDocsHtml());
|
||||
return;
|
||||
@@ -235,6 +242,16 @@ function sendHtml(res: ServerResponse, status: number, html: string): void {
|
||||
res.end(html);
|
||||
}
|
||||
|
||||
function sendJavascript(res: ServerResponse, status: number, source: string): void {
|
||||
if (res.headersSent) return;
|
||||
res.writeHead(status, {
|
||||
"Content-Type": "application/javascript; charset=utf-8",
|
||||
"Content-Length": Buffer.byteLength(source, "utf-8"),
|
||||
"Cache-Control": "public, max-age=86400",
|
||||
});
|
||||
res.end(source);
|
||||
}
|
||||
|
||||
function sendError(res: ServerResponse, status: number, message: string): void {
|
||||
sendJson(res, status, { error: true, message });
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- `embedded-openapi.ts`:内嵌 `specs/openapi.json`(包装层)与 `specs/openapi.raw.json`(原生下游)两份 OpenAPI 规范,供 `hose-use openapi` 命令与 HTTP 文档页读取;产物由 `scripts/generate/bundle-openapi.ts` / `scripts/generate/generate-raw-openapi.ts` 生成。
|
||||
- `embedded-skill.ts`:内嵌 `skills/hose-use/` 全量 Skill 文件(`EMBEDDED_SKILL_FILES`),支持 `hose-use skill install --yes` 一键安装到全局目录,并在编译二进制运行时自动同步(`syncGlobalSkillIfPresent`)。
|
||||
- `embedded-webui.ts`:内嵌 AI PRO 本地 Web 控制台的单文件 HTML,供 `GET /report` 返回。
|
||||
- `embedded-docs.ts`:内嵌 `/docs` 交互式文档使用的 Scalar 浏览器运行时,供 `GET /static/scalar.js` 返回。
|
||||
- `runtime.ts`:二进制运行态自省——`isCompiledBinary` 判定编译态、`resolveAppRoot` 解析应用根目录、`resolveDefaultLauncher` 解析启动配置。
|
||||
|
||||
## Web 控制台内嵌产物
|
||||
@@ -22,6 +23,19 @@ bun run web:build # 生成 src/packaging/generated/webui.txt
|
||||
- 该生成物**必须随 git 提交**,与 `specs/*.json` 同理——编译二进制与 CI 不需要安装前端依赖。
|
||||
- `.webui-dist/` 是 Vite 中间产物,已被 `.gitignore` 忽略。
|
||||
|
||||
## 离线 API 文档运行时
|
||||
|
||||
`GET /docs` 的 Scalar 交互式文档不再引用 CDN。`scripts/build/build-docs.mjs` 固定 `@scalar/api-reference@1.25.101`,下载后按 SHA-256 校验,生成 `src/packaging/generated/scalar-standalone.js.txt`:
|
||||
|
||||
```bash
|
||||
bun run docs:fetch # 仅升级 Scalar 版本时需要联网
|
||||
```
|
||||
|
||||
- 生成物随 git 提交;daemon 的 `GET /static/scalar.js` 返回它,`/docs` 用相对路径加载,运行时完全离线。
|
||||
- 后缀用 `.txt` 与 webui 同理,避开 Bun 对 `.js` / `.html` 的非字符串类型推断。
|
||||
- `renderDocsHtml()` 里加了 CSP(`connect-src 'self'`):Scalar 内置一个"加载示例规范"分支会 `fetch` jsdelivr 的 galaxy.yaml,我们的页面用 `data-url="/openapi.json"` 不走该分支,CSP 再兜一层,保证任何情况下都发不出外网请求。
|
||||
- 生成物约 2.7 MiB,二进制体积因此增加约 2.9 MB。
|
||||
|
||||
## 依赖约束
|
||||
|
||||
- 仅可被入口层与 `cli/` 导入;不得反向依赖 `domains/`。
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* /docs 交互式 API 文档的 Scalar 浏览器运行时(固定版本,随源码提交)。
|
||||
*
|
||||
* 由 scripts/build/build-docs.mjs 从 jsdelivr 拉取并校验 SHA-256 后生成,
|
||||
* 运行时由本地 daemon 的 GET /static/scalar.js 提供,不访问任何 CDN。
|
||||
*/
|
||||
import scalarStandaloneJs from "./generated/scalar-standalone.js.txt" with { type: "text" };
|
||||
|
||||
export function getScalarStandaloneJs(): string {
|
||||
return scalarStandaloneJs;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user