bailinghub 0.3.0 → 0.3.2-rc.1
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/.env.example +3 -0
- package/README.en.md +2 -2
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/demo/business/server.mjs +107 -59
- package/docker-compose.images.yml +2 -2
- package/docs/CHANGELOG.en.md +10 -0
- package/docs/CHANGELOG.md +10 -0
- package/docs/DEMO.md +25 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -3
- package/docs/INDEPENDENT_VALIDATION.md +4 -3
- package/docs/README.en.md +2 -0
- package/docs/README.md +2 -0
- package/docs/RELEASE_NOTES_v0.3.1.en.md +44 -0
- package/docs/RELEASE_NOTES_v0.3.1.md +44 -0
- package/package.json +5 -2
- package/scripts/check-doc-links.mjs +1 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-package-artifact.mjs +2 -1
- package/scripts/check-release-consistency.mjs +57 -23
- package/scripts/check-release-consistency.test.mjs +58 -3
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +1 -0
- package/scripts/seed-demo.ts +24 -99
- package/scripts/validate-examples.mjs +6 -4
- package/scripts/verify-github-repo.mjs +2 -1
- package/sql/054_demo_dataset_state.sql +12 -0
- package/src/adapters/llm/file.ts +2 -2
- package/src/app/kernel.ts +3 -0
- package/src/core/config/config.test.ts +69 -0
- package/src/core/config/config.ts +54 -0
- package/src/infrastructure/config/config-chat-repository.ts +12 -1
- package/src/infrastructure/config/config-client-repository.ts +21 -2
- package/src/infrastructure/config/config-route-repository.ts +12 -1
- package/src/infrastructure/config/config-target-repository.ts +12 -1
- package/src/infrastructure/config/config-tool-provider-repository.ts +12 -1
- package/src/routes/admin-default.ts +2 -0
- package/src/routes/admin-demo-dataset.test.ts +93 -0
- package/src/routes/admin-demo-dataset.ts +83 -0
- package/src/routes/admin-host.test.ts +10 -1
- package/src/routes/admin.ts +14 -0
- package/src/services/demo-business-profile.test.ts +230 -0
- package/src/services/demo-dataset.test.ts +369 -0
- package/src/services/demo-dataset.ts +872 -0
- package/web/console/assets/{Accounts-Dwzm4D_V.js → Accounts-08VltF2i.js} +1 -1
- package/web/console/assets/{Approvals-BxhuI0ku.js → Approvals-CqgmsMau.js} +1 -1
- package/web/console/assets/{Audit-dFAbGynl.js → Audit-bPlpSQt3.js} +1 -1
- package/web/console/assets/{BrandLockup-BtZyvkM5.js → BrandLockup-DhX07g3G.js} +1 -1
- package/web/console/assets/{Channels-Dqg4-_yr.js → Channels-BZe0pLgx.js} +1 -1
- package/web/console/assets/{ChatEntries-CEGZ3NnJ.js → ChatEntries-Ca0lcGqn.js} +1 -1
- package/web/console/assets/{Clients-C0QD1x7g.js → Clients-BVVZfX3r.js} +1 -1
- package/web/console/assets/{Cost-BAJqLhpK.js → Cost-DANcjr_p.js} +1 -1
- package/web/console/assets/{Credentials-D_GDRgWi.js → Credentials-D_8tP2Xa.js} +1 -1
- package/web/console/assets/{Diagnostics-BWYnDxRj.js → Diagnostics-Bw1WImFe.js} +1 -1
- package/web/console/assets/{Executors-Cmryk4Vk.js → Executors-fuieN2Sl.js} +1 -1
- package/web/console/assets/{Kb-BSXQE0Fa.js → Kb-BaMi_7xf.js} +1 -1
- package/web/console/assets/{Login-BnBPqC8Z.js → Login-Cmz2ppY8.js} +1 -1
- package/web/console/assets/{Projects-CNHx4L_7.js → Projects-D6xIgFB3.js} +1 -1
- package/web/console/assets/{Routes-u5cEAEXQ.js → Routes-B90i3ZNa.js} +1 -1
- package/web/console/assets/{Runs-BeFUR77_.js → Runs-9qpwotOj.js} +1 -1
- package/web/console/assets/Setup-BIjCiA2i.js +1 -0
- package/web/console/assets/Setup-BuyKFofL.css +1 -0
- package/web/console/assets/Shell-BVIjmoY8.css +1 -0
- package/web/console/assets/Shell-Dm6eFcl1.js +1 -0
- package/web/console/assets/{StorageBuckets-DMXRJxUA.js → StorageBuckets-DY8WuJlM.js} +1 -1
- package/web/console/assets/{SystemSettings-B72F-loY.js → SystemSettings-O_NMPzq_.js} +1 -1
- package/web/console/assets/{SystemStatus-hOj_TPYE.js → SystemStatus-Cok3S7S3.js} +1 -1
- package/web/console/assets/{Targets-UVVf7twC.js → Targets-YWBoxqvy.js} +1 -1
- package/web/console/assets/{Tools-ihkr9R9x.js → Tools-BgXDw7Mg.js} +1 -1
- package/web/console/assets/{index-DxvruykG.js → index-S_J0I0Zh.js} +2 -2
- package/web/console/assets/{request-BisL2T9B.js → request-FM608Kfz.js} +1 -1
- package/web/console/assets/{schema-CzpUpoLk.js → schema-DWnFqTkB.js} +1 -1
- package/web/console/index.html +1 -1
- package/web-admin/package-lock.json +3 -3
- package/web-admin/src/layout/Shell.vue +5 -4
- package/web-admin/src/pages/Setup.vue +12 -9
- package/web/console/assets/Setup-BjZfrmfN.js +0 -1
- package/web/console/assets/Setup-QjlHZKdB.css +0 -1
- package/web/console/assets/Shell-CbGNTN91.css +0 -1
- package/web/console/assets/Shell-EJuYf3OO.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bailinghub",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2-rc.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Open-source ACC runtime and agent control plane for existing business systems.",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22"
|
|
48
48
|
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"tag": "next"
|
|
51
|
+
},
|
|
49
52
|
"scripts": {
|
|
50
53
|
"start": "tsx src/server.ts",
|
|
51
54
|
"dev": "tsx watch src/server.ts",
|
|
@@ -105,7 +108,7 @@
|
|
|
105
108
|
"dependencies": {
|
|
106
109
|
"mammoth": "^1.12.0",
|
|
107
110
|
"mysql2": "^3.11.4",
|
|
108
|
-
"pdfjs-dist": "^
|
|
111
|
+
"pdfjs-dist": "^6.2.108",
|
|
109
112
|
"tsx": "^4.19.2",
|
|
110
113
|
"yaml": "^2.9.0"
|
|
111
114
|
},
|
|
@@ -97,6 +97,7 @@ const englishCompanions = {
|
|
|
97
97
|
'docs/RELEASE_NOTES_v0.1.16.md': 'docs/RELEASE_NOTES_v0.1.16.en.md',
|
|
98
98
|
'docs/RELEASE_NOTES_v0.2.0.md': 'docs/RELEASE_NOTES_v0.2.0.en.md',
|
|
99
99
|
'docs/RELEASE_NOTES_v0.3.0.md': 'docs/RELEASE_NOTES_v0.3.0.en.md',
|
|
100
|
+
'docs/RELEASE_NOTES_v0.3.1.md': 'docs/RELEASE_NOTES_v0.3.1.en.md',
|
|
100
101
|
'docs/TOOLS_DESIGN.md': 'docs/TOOLS_DESIGN.en.md',
|
|
101
102
|
'docs/TOOLS_MODEL.md': 'docs/TOOLS_MODEL.en.md',
|
|
102
103
|
'docs/AI友好工具设计指南.md': 'docs/AI_FRIENDLY_TOOLS.en.md',
|
|
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
|
|
|
9
9
|
NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
|
|
10
10
|
PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
11
11
|
TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
|
|
12
|
-
[ -n "$TAG" ] || TAG="0.3.
|
|
12
|
+
[ -n "$TAG" ] || TAG="0.3.1"
|
|
13
13
|
MYSQL_TAG="${BAILING_MYSQL_IMAGE_TAG:-8.4}"
|
|
14
14
|
MYSQL_IMAGE="${BAILING_MYSQL_IMAGE:-$REGISTRY/$NAMESPACE/bailing-mysql:$MYSQL_TAG}"
|
|
15
15
|
PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
|
|
@@ -53,7 +53,8 @@ const requiredFiles = [
|
|
|
53
53
|
'src/infrastructure/schema/core-schema-migrator.ts',
|
|
54
54
|
'src/infrastructure/schema/retired-migrations.ts',
|
|
55
55
|
'sql/001_init_state.sql',
|
|
56
|
-
'sql/
|
|
56
|
+
'sql/054_demo_dataset_state.sql',
|
|
57
|
+
'demo/business/server.mjs',
|
|
57
58
|
'web/console/index.html',
|
|
58
59
|
'web/widget/widget.js',
|
|
59
60
|
];
|
|
@@ -3,6 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
|
|
5
5
|
const VERSION_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
6
|
+
const STABLE_VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
6
7
|
|
|
7
8
|
export const releaseConsistencyFiles = [
|
|
8
9
|
'package.json',
|
|
@@ -50,6 +51,20 @@ function normalizeExpectedVersion(value) {
|
|
|
50
51
|
return String(value).trim().replace(/^v/, '');
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
function currentStableVersion(changelog, findings) {
|
|
55
|
+
const version = extractSingleVersion(
|
|
56
|
+
changelog,
|
|
57
|
+
/^## v(?<version>\d+\.\d+\.\d+) /m,
|
|
58
|
+
'docs/CHANGELOG.md',
|
|
59
|
+
'current stable release entry',
|
|
60
|
+
findings,
|
|
61
|
+
);
|
|
62
|
+
if (version && !STABLE_VERSION_RE.test(version)) {
|
|
63
|
+
findings.push(`docs/CHANGELOG.md: current stable release entry must be semantic, received ${version}`);
|
|
64
|
+
}
|
|
65
|
+
return version;
|
|
66
|
+
}
|
|
67
|
+
|
|
53
68
|
function extractSingleVersion(text, regex, file, label, findings) {
|
|
54
69
|
const match = text.match(regex);
|
|
55
70
|
if (!match?.groups?.version) {
|
|
@@ -76,11 +91,24 @@ export function checkReleaseConsistency({ root = process.cwd(), expected = '' }
|
|
|
76
91
|
const findings = [];
|
|
77
92
|
const pkg = readJson(root, 'package.json', findings);
|
|
78
93
|
const version = String(pkg.version ?? '').trim();
|
|
94
|
+
const isPrerelease = version.includes('-');
|
|
95
|
+
const publishTag = String(pkg.publishConfig?.tag ?? '').trim();
|
|
79
96
|
|
|
80
97
|
if (!VERSION_RE.test(version)) {
|
|
81
98
|
findings.push(`package.json: version must be semantic, received ${version || '<empty>'}`);
|
|
82
99
|
}
|
|
83
100
|
|
|
101
|
+
if (isPrerelease && publishTag !== 'next') {
|
|
102
|
+
findings.push(
|
|
103
|
+
`package.json: prerelease versions must use publishConfig.tag "next", received ${publishTag || '<empty>'}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (!isPrerelease && publishTag && publishTag !== 'latest') {
|
|
107
|
+
findings.push(
|
|
108
|
+
`package.json: stable versions may only use publishConfig.tag "latest" or omit it, received ${publishTag}`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
84
112
|
const expectedVersion = normalizeExpectedVersion(
|
|
85
113
|
expected
|
|
86
114
|
|| (process.env.GITHUB_REF_TYPE === 'tag' ? process.env.GITHUB_REF_NAME : ''),
|
|
@@ -93,6 +121,9 @@ export function checkReleaseConsistency({ root = process.cwd(), expected = '' }
|
|
|
93
121
|
expectVersion(String(lock.version ?? ''), version, 'package-lock.json', 'top-level version', findings);
|
|
94
122
|
expectVersion(String(lock.packages?.['']?.version ?? ''), version, 'package-lock.json', 'root package version', findings);
|
|
95
123
|
|
|
124
|
+
const changelog = readText(root, 'docs/CHANGELOG.md', findings);
|
|
125
|
+
const stableVersion = isPrerelease ? currentStableVersion(changelog, findings) : version;
|
|
126
|
+
|
|
96
127
|
const compose = readText(root, 'docker-compose.images.yml', findings);
|
|
97
128
|
for (const image of ['bailinghub', 'bailing-demo-business']) {
|
|
98
129
|
const escaped = image.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
@@ -103,7 +134,7 @@ export function checkReleaseConsistency({ root = process.cwd(), expected = '' }
|
|
|
103
134
|
`${image} default image tag`,
|
|
104
135
|
findings,
|
|
105
136
|
);
|
|
106
|
-
expectVersion(imageVersion,
|
|
137
|
+
expectVersion(imageVersion, stableVersion, 'docker-compose.images.yml', `${image} default image tag`, findings);
|
|
107
138
|
}
|
|
108
139
|
|
|
109
140
|
const fallbackChecks = [
|
|
@@ -126,55 +157,55 @@ export function checkReleaseConsistency({ root = process.cwd(), expected = '' }
|
|
|
126
157
|
for (const check of fallbackChecks) {
|
|
127
158
|
const text = readText(root, check.file, findings);
|
|
128
159
|
const actual = extractSingleVersion(text, check.regex, check.file, check.label, findings);
|
|
129
|
-
expectVersion(actual,
|
|
160
|
+
expectVersion(actual, stableVersion, check.file, check.label, findings);
|
|
130
161
|
}
|
|
131
162
|
|
|
132
163
|
for (const [file, baselineText] of [
|
|
133
|
-
['docs/INDEPENDENT_VALIDATION.md', `稳定基线:\`v${
|
|
134
|
-
['docs/INDEPENDENT_VALIDATION.en.md', `Stable baseline: \`v${
|
|
164
|
+
['docs/INDEPENDENT_VALIDATION.md', `稳定基线:\`v${stableVersion}\``],
|
|
165
|
+
['docs/INDEPENDENT_VALIDATION.en.md', `Stable baseline: \`v${stableVersion}\``],
|
|
135
166
|
]) {
|
|
136
167
|
const text = readText(root, file, findings);
|
|
137
168
|
expectContains(text, baselineText, file, 'current validation baseline', findings);
|
|
138
|
-
expectContains(text, `--branch v${
|
|
139
|
-
expectContains(text, `RELEASE_NOTES_v${
|
|
169
|
+
expectContains(text, `--branch v${stableVersion}`, file, 'current validation clone command', findings);
|
|
170
|
+
expectContains(text, `RELEASE_NOTES_v${stableVersion}`, file, 'current release-note link', findings);
|
|
140
171
|
}
|
|
141
172
|
|
|
142
173
|
const issueTemplate = readText(root, '.github/ISSUE_TEMPLATE/independent_validation.yml', findings);
|
|
143
174
|
expectContains(
|
|
144
175
|
issueTemplate,
|
|
145
|
-
`placeholder: "v${
|
|
176
|
+
`placeholder: "v${stableVersion};`,
|
|
146
177
|
'.github/ISSUE_TEMPLATE/independent_validation.yml',
|
|
147
178
|
'current validation placeholder',
|
|
148
179
|
findings,
|
|
149
180
|
);
|
|
150
181
|
|
|
151
182
|
const releaseNotes = [
|
|
152
|
-
`docs/RELEASE_NOTES_v${
|
|
153
|
-
`docs/RELEASE_NOTES_v${
|
|
183
|
+
`docs/RELEASE_NOTES_v${stableVersion}.md`,
|
|
184
|
+
`docs/RELEASE_NOTES_v${stableVersion}.en.md`,
|
|
154
185
|
];
|
|
155
186
|
for (const file of releaseNotes) {
|
|
156
187
|
readText(root, file, findings);
|
|
157
188
|
}
|
|
158
189
|
|
|
159
190
|
const referenceChecks = [
|
|
160
|
-
['README.md', `docs/RELEASE_NOTES_v${
|
|
161
|
-
['README.en.md', `docs/RELEASE_NOTES_v${
|
|
162
|
-
['docs/README.md', `RELEASE_NOTES_v${
|
|
163
|
-
['docs/README.md', `RELEASE_NOTES_v${
|
|
164
|
-
['docs/README.en.md', `RELEASE_NOTES_v${
|
|
165
|
-
['docs/README.en.md', `RELEASE_NOTES_v${
|
|
166
|
-
['docs/CHANGELOG.md', `## v${
|
|
167
|
-
['docs/CHANGELOG.en.md', `## v${
|
|
168
|
-
['scripts/check-doc-links.mjs', `docs/RELEASE_NOTES_v${
|
|
169
|
-
['scripts/release-audit.mjs', `docs/RELEASE_NOTES_v${
|
|
170
|
-
['scripts/verify-github-repo.mjs', `docs/RELEASE_NOTES_v${
|
|
191
|
+
['README.md', `docs/RELEASE_NOTES_v${stableVersion}.md`],
|
|
192
|
+
['README.en.md', `docs/RELEASE_NOTES_v${stableVersion}.en.md`],
|
|
193
|
+
['docs/README.md', `RELEASE_NOTES_v${stableVersion}.md`],
|
|
194
|
+
['docs/README.md', `RELEASE_NOTES_v${stableVersion}.en.md`],
|
|
195
|
+
['docs/README.en.md', `RELEASE_NOTES_v${stableVersion}.md`],
|
|
196
|
+
['docs/README.en.md', `RELEASE_NOTES_v${stableVersion}.en.md`],
|
|
197
|
+
['docs/CHANGELOG.md', `## v${stableVersion} `],
|
|
198
|
+
['docs/CHANGELOG.en.md', `## v${stableVersion} `],
|
|
199
|
+
['scripts/check-doc-links.mjs', `docs/RELEASE_NOTES_v${stableVersion}.md`],
|
|
200
|
+
['scripts/release-audit.mjs', `docs/RELEASE_NOTES_v${stableVersion}.md`],
|
|
201
|
+
['scripts/verify-github-repo.mjs', `docs/RELEASE_NOTES_v${stableVersion}.md`],
|
|
171
202
|
];
|
|
172
203
|
for (const [file, expectedText] of referenceChecks) {
|
|
173
204
|
const text = readText(root, file, findings);
|
|
174
205
|
expectContains(text, expectedText, file, 'current release reference', findings);
|
|
175
206
|
}
|
|
176
207
|
|
|
177
|
-
return { version, expectedVersion, findings };
|
|
208
|
+
return { version, stableVersion, expectedVersion, isPrerelease, publishTag, findings };
|
|
178
209
|
}
|
|
179
210
|
|
|
180
211
|
function parseExpected(argv) {
|
|
@@ -191,8 +222,11 @@ function runCli() {
|
|
|
191
222
|
process.exitCode = 1;
|
|
192
223
|
return;
|
|
193
224
|
}
|
|
194
|
-
const ref = result.expectedVersion ?
|
|
195
|
-
|
|
225
|
+
const ref = result.expectedVersion ? `, release ref ${result.expectedVersion}` : '';
|
|
226
|
+
const channel = result.isPrerelease
|
|
227
|
+
? `, stable release surface ${result.stableVersion}, npm tag ${result.publishTag}`
|
|
228
|
+
: `, npm tag ${result.publishTag || 'latest (default)'}`;
|
|
229
|
+
console.log(`Release consistency check passed for ${result.version}${channel}${ref}.`);
|
|
196
230
|
}
|
|
197
231
|
|
|
198
232
|
const entry = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : '';
|
|
@@ -18,21 +18,54 @@ function createFixture() {
|
|
|
18
18
|
mkdirSync(dirname(destination), { recursive: true });
|
|
19
19
|
cpSync(source, destination);
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const { stableVersion } = checkReleaseConsistency({ root: repoRoot });
|
|
22
22
|
for (const suffix of ['.md', '.en.md']) {
|
|
23
|
-
const source = resolve(repoRoot, `docs/RELEASE_NOTES_v${
|
|
24
|
-
const destination = resolve(root, `docs/RELEASE_NOTES_v${
|
|
23
|
+
const source = resolve(repoRoot, `docs/RELEASE_NOTES_v${stableVersion}${suffix}`);
|
|
24
|
+
const destination = resolve(root, `docs/RELEASE_NOTES_v${stableVersion}${suffix}`);
|
|
25
25
|
mkdirSync(dirname(destination), { recursive: true });
|
|
26
26
|
cpSync(source, destination);
|
|
27
27
|
}
|
|
28
28
|
return root;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function updateJson(root, relativePath, update) {
|
|
32
|
+
const path = resolve(root, relativePath);
|
|
33
|
+
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
34
|
+
update(value);
|
|
35
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
test('current release surface is internally consistent', () => {
|
|
32
39
|
const result = checkReleaseConsistency({ root: repoRoot });
|
|
33
40
|
assert.deepEqual(result.findings, []);
|
|
41
|
+
assert.equal(result.version, '0.3.2-rc.1');
|
|
42
|
+
assert.equal(result.stableVersion, '0.3.1');
|
|
43
|
+
assert.equal(result.publishTag, 'next');
|
|
34
44
|
});
|
|
35
45
|
|
|
46
|
+
for (const [label, tag] of [
|
|
47
|
+
['missing', undefined],
|
|
48
|
+
['wrong', 'latest'],
|
|
49
|
+
]) {
|
|
50
|
+
test(`RC ${label} next publish tag is rejected`, () => {
|
|
51
|
+
const root = createFixture();
|
|
52
|
+
try {
|
|
53
|
+
updateJson(root, 'package.json', (pkg) => {
|
|
54
|
+
if (tag === undefined) delete pkg.publishConfig;
|
|
55
|
+
else pkg.publishConfig = { tag };
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = checkReleaseConsistency({ root });
|
|
59
|
+
assert.ok(
|
|
60
|
+
result.findings.some((finding) => finding.includes('prerelease versions must use publishConfig.tag "next"')),
|
|
61
|
+
result.findings.join('\n'),
|
|
62
|
+
);
|
|
63
|
+
} finally {
|
|
64
|
+
rmSync(root, { recursive: true, force: true });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
36
69
|
test('mismatched image tag is rejected before release', () => {
|
|
37
70
|
const root = createFixture();
|
|
38
71
|
try {
|
|
@@ -61,3 +94,25 @@ test('tag and package version mismatch is rejected', () => {
|
|
|
61
94
|
);
|
|
62
95
|
});
|
|
63
96
|
|
|
97
|
+
test('stable version cannot retain the next publish tag', () => {
|
|
98
|
+
const root = createFixture();
|
|
99
|
+
try {
|
|
100
|
+
const { stableVersion } = checkReleaseConsistency({ root });
|
|
101
|
+
updateJson(root, 'package.json', (pkg) => {
|
|
102
|
+
pkg.version = stableVersion;
|
|
103
|
+
pkg.publishConfig = { tag: 'next' };
|
|
104
|
+
});
|
|
105
|
+
updateJson(root, 'package-lock.json', (lock) => {
|
|
106
|
+
lock.version = stableVersion;
|
|
107
|
+
lock.packages[''].version = stableVersion;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const result = checkReleaseConsistency({ root });
|
|
111
|
+
assert.ok(
|
|
112
|
+
result.findings.some((finding) => finding.includes('stable versions may only use publishConfig.tag "latest" or omit it')),
|
|
113
|
+
result.findings.join('\n'),
|
|
114
|
+
);
|
|
115
|
+
} finally {
|
|
116
|
+
rmSync(root, { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
});
|
package/scripts/install.sh
CHANGED
|
@@ -275,7 +275,7 @@ write_env() {
|
|
|
275
275
|
TOOL_SECRET="${DEMO_TOOL_SECRET:-$(secret)}"
|
|
276
276
|
CLIENT_TOKEN="${DEMO_CLIENT_TOKEN:-$(secret)}"
|
|
277
277
|
IMAGE_TAG="${BAILING_IMAGE_TAG:-$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$APP_DIR/package.json" | head -1)}"
|
|
278
|
-
[ -n "$IMAGE_TAG" ] || IMAGE_TAG="0.3.
|
|
278
|
+
[ -n "$IMAGE_TAG" ] || IMAGE_TAG="0.3.1"
|
|
279
279
|
IMAGE_REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_IMAGE_REGISTRY}"
|
|
280
280
|
IMAGE_NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_IMAGE_NAMESPACE}"
|
|
281
281
|
cat > "$ENV_FILE" <<EOF
|
|
@@ -9,7 +9,7 @@ REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_REGISTRY}"
|
|
|
9
9
|
NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_NAMESPACE}"
|
|
10
10
|
PACKAGE_VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' package.json | head -1)"
|
|
11
11
|
TAG="${BAILING_IMAGE_TAG:-$PACKAGE_VERSION}"
|
|
12
|
-
[ -n "$TAG" ] || TAG="0.3.
|
|
12
|
+
[ -n "$TAG" ] || TAG="0.3.1"
|
|
13
13
|
NODE_IMAGE="${BAILING_NODE_IMAGE:-node:22-bookworm-slim}"
|
|
14
14
|
PLATFORM="${BAILING_IMAGE_PLATFORM:-linux/amd64}"
|
|
15
15
|
PUSH="${BAILING_PUSH_IMAGES:-0}"
|
package/scripts/seed-demo.ts
CHANGED
|
@@ -1,116 +1,41 @@
|
|
|
1
|
-
// 初始化开源体验 demo
|
|
2
|
-
//
|
|
1
|
+
// 初始化开源体验 demo。演示数据的定义、事务和所有权规则由 Core service 单一实现,
|
|
2
|
+
// CLI 只负责启动时调用,避免与控制台 API 长成两套数据仓储逻辑。
|
|
3
3
|
import { loadConfig } from '../src/core/config/config';
|
|
4
4
|
import { ConfigStore } from '../src/infrastructure/config/configstore';
|
|
5
5
|
import { bootstrapInitialAdmin } from '../src/app/admin-bootstrap';
|
|
6
|
-
import
|
|
7
|
-
import { parseOpenApiSpec } from '../src/core/contracts/openapi-tools';
|
|
6
|
+
import { DemoDatasetConflictError, DemoDatasetService } from '../src/services/demo-dataset';
|
|
8
7
|
|
|
9
8
|
const cfg = loadConfig();
|
|
10
9
|
if (cfg.state.backend !== 'mysql') {
|
|
11
10
|
console.error('demo seed 需要 mysql 后端');
|
|
12
11
|
process.exit(1);
|
|
13
12
|
}
|
|
13
|
+
if (!cfg.demoDataset) {
|
|
14
|
+
console.error('demo seed 需要同时配置 DEMO_BUSINESS_URL 与 DEMO_TOOL_SECRET');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
const demoBusinessUrl = String(process.env.DEMO_BUSINESS_URL ?? 'http://127.0.0.1:19080').replace(/\/+$/, '');
|
|
16
|
-
const toolSecret = String(process.env.DEMO_TOOL_SECRET ?? 'demo-tool-secret-change-me');
|
|
17
|
-
const clientToken = String(process.env.DEMO_CLIENT_TOKEN ?? 'bailing-demo-client-token');
|
|
18
18
|
const adminPassword = String(process.env.BAILING_DEMO_ADMIN_PASSWORD ?? 'bailing-demo-admin');
|
|
19
19
|
const adminConfig = cfg.bootstrapAdmin ?? { username: 'admin', password: adminPassword };
|
|
20
|
-
|
|
21
|
-
async function fetchTextWithRetry(url: string, attempts = 30): Promise<string> {
|
|
22
|
-
let last = '';
|
|
23
|
-
for (let i = 0; i < attempts; i++) {
|
|
24
|
-
try {
|
|
25
|
-
const r = await fetch(url, { signal: AbortSignal.timeout(3000) });
|
|
26
|
-
if (r.ok) return await r.text();
|
|
27
|
-
last = `HTTP ${r.status}`;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
last = e instanceof Error ? e.message : String(e);
|
|
30
|
-
}
|
|
31
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`demo business spec 不可用:${last}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const specUrl = `${demoBusinessUrl}/.well-known/bailing/tools.json`;
|
|
37
|
-
const specText = await fetchTextWithRetry(specUrl);
|
|
38
|
-
const parsedSpec = parseOpenApiSpec(specText);
|
|
39
|
-
if (!parsedSpec.ok) throw new Error(parsedSpec.error);
|
|
40
|
-
const specJson = parsedSpec.canonicalJson;
|
|
41
|
-
|
|
42
20
|
const store = new ConfigStore(cfg.state.mysql);
|
|
43
21
|
await store.init();
|
|
44
22
|
const adminBootstrap = await bootstrapInitialAdmin(adminConfig, { admins: store.admins });
|
|
45
23
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
spec_refreshed_at: new Date().toISOString(),
|
|
63
|
-
secret: toolSecret,
|
|
64
|
-
log_payload: true,
|
|
65
|
-
timeout_ms: 8000,
|
|
66
|
-
rate_limit_per_min: 120,
|
|
67
|
-
auto_refresh_min: 10,
|
|
68
|
-
enabled: true,
|
|
69
|
-
description: 'Docker Compose 内置 demo 业务系统:订单、工单、退款示例工具。',
|
|
70
|
-
};
|
|
71
|
-
await store.toolProviders.upsert(provider);
|
|
72
|
-
|
|
73
|
-
const route: Route = {
|
|
74
|
-
route_key: 'demo_support',
|
|
75
|
-
name: 'Demo 售后助手',
|
|
76
|
-
enabled: true,
|
|
77
|
-
target: 'demo-agent',
|
|
78
|
-
target_config: {},
|
|
79
|
-
profile: 'demo',
|
|
80
|
-
permission: 'readonly',
|
|
81
|
-
session_policy: 'per_key',
|
|
82
|
-
session_key_field: 'visitor_uid',
|
|
83
|
-
tools: {
|
|
84
|
-
sources: [{
|
|
85
|
-
provider: 'demo-business',
|
|
86
|
-
allow: ['demo.order.*', 'demo.ticket.*', 'demo.refund.*', 'demo.failure.*'],
|
|
87
|
-
subject_field: 'operator_uid',
|
|
88
|
-
}],
|
|
89
|
-
max_calls: 5,
|
|
90
|
-
approval: { type: 'business_webhook', url: `${demoBusinessUrl}/approvals` },
|
|
91
|
-
},
|
|
92
|
-
memory: { recent_messages: 8, recent_budget_chars: 6000 },
|
|
93
|
-
retry: { max: 1, backoff_ms: 1000 },
|
|
94
|
-
description: '开源体验路由:用 demo-agent 调用 demo 业务工具,展示工具治理闭环。',
|
|
95
|
-
};
|
|
96
|
-
await store.routes.upsert(route);
|
|
97
|
-
|
|
98
|
-
await store.clients.upsert({
|
|
99
|
-
app_id: 'demo-app',
|
|
100
|
-
name: 'Demo 业务系统',
|
|
101
|
-
allowed_routes: ['demo_support'],
|
|
102
|
-
allowed_channels: [],
|
|
103
|
-
rate_limit_per_min: 60,
|
|
104
|
-
enabled: true,
|
|
105
|
-
description: 'Docker Compose 内置 demo 接入方。',
|
|
106
|
-
}, true);
|
|
107
|
-
await store.db.query('UPDATE bz_clients SET token=? WHERE app_id=?', [clientToken, 'demo-app']);
|
|
24
|
+
try {
|
|
25
|
+
const result = await new DemoDatasetService(store, cfg.demoDataset).import();
|
|
26
|
+
console.log('✓ demo 配置已就绪');
|
|
27
|
+
console.log(` Hub: http://localhost:${cfg.server.port}`);
|
|
28
|
+
console.log(' Console: http://localhost:18900/console/');
|
|
29
|
+
console.log(` Admin: ${adminBootstrap === 'created' ? adminConfig.username : 'existing account preserved'}`);
|
|
30
|
+
console.log(' Demo route: demo_support');
|
|
31
|
+
console.log(` Demo business: ${cfg.demoDataset.businessBaseUrl}`);
|
|
32
|
+
console.log(` Demo profile: ${cfg.demoDataset.profile}`);
|
|
33
|
+
console.log(` Owned resources: ${result.created.join(', ')}`);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (!(error instanceof DemoDatasetConflictError)) throw error;
|
|
36
|
+
// 0.3.1 之前的 Docker demo 没有 durable marker。不猜测旧对象所有权,也不让警告阻断 Core 启动。
|
|
37
|
+
console.warn(`! demo 配置未自动导入:${error.message}`);
|
|
38
|
+
console.warn(' 请在控制台核对同名对象;Core 未覆盖或删除任何现有配置。');
|
|
39
|
+
}
|
|
108
40
|
|
|
109
|
-
|
|
110
|
-
console.log(` Hub: http://localhost:${cfg.server.port}`);
|
|
111
|
-
console.log(' Console: http://localhost:18900/console/');
|
|
112
|
-
console.log(` Admin: ${adminBootstrap === 'created' ? adminConfig.username : 'existing account preserved'}`);
|
|
113
|
-
console.log(' Demo route: demo_support');
|
|
114
|
-
console.log(` Demo client token: ${clientToken}`);
|
|
115
|
-
console.log(` Demo business tools: ${specUrl}`);
|
|
116
|
-
process.exit(0);
|
|
41
|
+
await store.close?.();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { checkReleaseConsistency } from './check-release-consistency.mjs';
|
|
2
3
|
|
|
3
4
|
const findings = [];
|
|
4
5
|
|
|
@@ -24,6 +25,7 @@ function requireIncludes(file, text, needle) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const pkg = parseJson('package.json');
|
|
28
|
+
const { stableVersion } = checkReleaseConsistency();
|
|
27
29
|
const config = parseJson('config.example.json');
|
|
28
30
|
const env = read('.env.example');
|
|
29
31
|
const compose = read('docker-compose.yml');
|
|
@@ -66,11 +68,11 @@ for (const [file, text] of [
|
|
|
66
68
|
if (/bailing\.bnopen\.cn/.test(text)) findings.push(`${file}: must not reference self-hosted internal instance`);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
if (
|
|
70
|
-
findings.push('docker-compose.images.yml: default bailinghub image tag must match
|
|
71
|
+
if (stableVersion && !composeImages.includes(`bailinghub:${stableVersion}`)) {
|
|
72
|
+
findings.push('docker-compose.images.yml: default bailinghub image tag must match stable release surface');
|
|
71
73
|
}
|
|
72
|
-
if (
|
|
73
|
-
findings.push('docker-compose.images.yml: default demo image tag must match
|
|
74
|
+
if (stableVersion && !composeImages.includes(`bailing-demo-business:${stableVersion}`)) {
|
|
75
|
+
findings.push('docker-compose.images.yml: default demo image tag must match stable release surface');
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
for (const required of [
|
|
@@ -121,6 +121,7 @@ const requiredFiles = [
|
|
|
121
121
|
'docs/RELEASE_NOTES_v0.1.16.md',
|
|
122
122
|
'docs/RELEASE_NOTES_v0.2.0.md',
|
|
123
123
|
'docs/RELEASE_NOTES_v0.3.0.md',
|
|
124
|
+
'docs/RELEASE_NOTES_v0.3.1.md',
|
|
124
125
|
'docs/CHANGELOG.md',
|
|
125
126
|
];
|
|
126
127
|
for (const file of requiredFiles) requireFile(file);
|
|
@@ -129,7 +130,7 @@ assertIncludes('README.md', [
|
|
|
129
130
|
'assets/bailinghub-lockup.png',
|
|
130
131
|
'assets/architecture-overview.zh-CN.png',
|
|
131
132
|
'THIRD_PARTY_NOTICES.md',
|
|
132
|
-
'https://trial.bailinghub.com/
|
|
133
|
+
'https://trial.bailinghub.com/register/',
|
|
133
134
|
'issues/new?template=bug_report.yml',
|
|
134
135
|
'curl -fsSL https://www.bailinghub.com/install.sh | sh',
|
|
135
136
|
'BAILING_INSTALL_MODE=source',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- BailingHub · Core 内置演示数据所有权标记。
|
|
2
|
+
-- 演示配置可以反复刷新和一键清理,但绝不能仅凭名字删除用户自建对象。
|
|
3
|
+
-- manifest_json 只记录 Core 已声明拥有的固定演示资源;运行账本不属于演示配置清理范围。
|
|
4
|
+
|
|
5
|
+
CREATE TABLE IF NOT EXISTS `bz_demo_datasets` (
|
|
6
|
+
`dataset_key` VARCHAR(64) NOT NULL COMMENT '内置演示数据集稳定标识',
|
|
7
|
+
`version` INT UNSIGNED NOT NULL COMMENT '演示数据定义版本',
|
|
8
|
+
`manifest_json` JSON NOT NULL COMMENT 'Core 拥有且允许刷新/清理的固定资源清单',
|
|
9
|
+
`imported_at` DATETIME NOT NULL,
|
|
10
|
+
`updated_at` DATETIME NOT NULL,
|
|
11
|
+
PRIMARY KEY (`dataset_key`)
|
|
12
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Core 内置演示数据持久所有权标记';
|
package/src/adapters/llm/file.ts
CHANGED
|
@@ -86,8 +86,8 @@ async function extractPdfText(ab: ArrayBuffer): Promise<FileExtractResult> {
|
|
|
86
86
|
standardFontDataUrl: new URL('../../../node_modules/pdfjs-dist/standard_fonts/', import.meta.url).href,
|
|
87
87
|
verbosity: pdfjs.VerbosityLevel.ERRORS,
|
|
88
88
|
});
|
|
89
|
-
const doc = await task.promise;
|
|
90
89
|
try {
|
|
90
|
+
const doc = await task.promise;
|
|
91
91
|
const pages: string[] = [];
|
|
92
92
|
for (let i = 1; i <= doc.numPages; i++) {
|
|
93
93
|
const page = await doc.getPage(i);
|
|
@@ -111,7 +111,7 @@ async function extractPdfText(ab: ArrayBuffer): Promise<FileExtractResult> {
|
|
|
111
111
|
text: text || 'PDF 未抽取到可用文本。它可能是扫描件/图片型 PDF,需要启用 OCR、视觉文档解析模型,或让业务侧提供文本化内容。',
|
|
112
112
|
};
|
|
113
113
|
} finally {
|
|
114
|
-
await
|
|
114
|
+
await task.destroy();
|
|
115
115
|
}
|
|
116
116
|
} catch (e) {
|
|
117
117
|
return { ok: false, parser: 'pdf', text: `PDF 文本抽取失败:${String(e).slice(0, 300)}` };
|
package/src/app/kernel.ts
CHANGED
|
@@ -61,6 +61,7 @@ import { handleRunFor, type RunApiDeps } from '../routes/run';
|
|
|
61
61
|
import { handleSendFor, type SendApiDeps } from '../routes/send';
|
|
62
62
|
import { handleWecomInboundFor, WecomRuntimeState, type WecomApiDeps } from '../routes/wecom';
|
|
63
63
|
import { WecomAccessTokenCache } from '../adapters/channels/wecom-api';
|
|
64
|
+
import { DemoDatasetService } from '../services/demo-dataset';
|
|
64
65
|
|
|
65
66
|
const timezoneClaims = new Map<string, number>();
|
|
66
67
|
const MAX_KERNEL_CLOSE_DRAIN_MS = 10 * 60_000;
|
|
@@ -178,6 +179,7 @@ export function createBailingHubKernel(input: CreateBailingHubKernelInputV1): Ba
|
|
|
178
179
|
queue: new Queue(cfg.concurrency, input.executionQueue),
|
|
179
180
|
serialScope: instanceKey,
|
|
180
181
|
});
|
|
182
|
+
const demoDataset = composition.cfgStore ? new DemoDatasetService(composition.cfgStore, cfg.demoDataset) : null;
|
|
181
183
|
const runtimeHelpers = createRuntimeContextHelpers({
|
|
182
184
|
cfg,
|
|
183
185
|
scopeResolver: edition.scopeResolver as ScopeResolver<Principal | null | undefined>,
|
|
@@ -329,6 +331,7 @@ export function createBailingHubKernel(input: CreateBailingHubKernelInputV1): Ba
|
|
|
329
331
|
targetRegistry,
|
|
330
332
|
httpMountPath,
|
|
331
333
|
localAdminManagement,
|
|
334
|
+
demoDataset,
|
|
332
335
|
}, method, path, req, res, principal),
|
|
333
336
|
handleApprovalDecision: (req, res, approvalId, url) => handleApprovalDecisionFor({
|
|
334
337
|
cfg,
|