mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-01 20:22:33 +00:00
* refactor(managed-agent): split server into Maven modules Separate contracts, orchestration, persistence, adapters, assembly, and verification while retaining the existing service delivery model. Move tests and build consumers together and document local evidence and pending CI acceptance. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * refactor(managed-agent): reduce configuration and SDK boilerplate Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * refactor(managed-agent): narrow contracts and simplify test scaffolding Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * fix(managed-agent): repair verification after module migration Resolve shared fixtures and worker paths from the Maven module root, update CI packaging assertions, and align existing test fixtures with the extracted contracts. Restore restricted Workspace constructors and remove redundant test visibility changes without altering inherited MySQL coverage. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * test(managed-agent): align remaining Harness and OSS fixtures Preserve SDK refusal messages and register the managed OSS adapter at fixture injection points. Keep the existing retry and client shutdown assertions intact. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * style(managed-agent): order Hosted cleanup Harness imports Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * test(managed-agent): fix recovery smoke fixture and import order Supply the required transcript coverage in the recovery browser fixture and wait for history before testing a complete handoff. Preserve its existing safety and submission assertions. Order the cleanup coordinator test imports for Checkstyle. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> --------- Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
87 lines
3 KiB
JavaScript
87 lines
3 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2026 Qwen Team
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { execFileSync } from 'node:child_process';
|
|
import { createHash } from 'node:crypto';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { parseArgs } from 'node:util';
|
|
import { copyManagedLocalRuntime } from './managed-local-package.js';
|
|
|
|
const { values } = parseArgs({
|
|
options: {
|
|
target: { type: 'string' },
|
|
'server-jar': { type: 'string' },
|
|
'jre-home': { type: 'string' },
|
|
'without-jre': { type: 'boolean' },
|
|
'out-dir': { type: 'string' },
|
|
help: { type: 'boolean', short: 'h' },
|
|
},
|
|
});
|
|
|
|
if (values.help) {
|
|
console.log(
|
|
'Usage: npm run package:managed-runtime -- --target TARGET --server-jar PATH (--jre-home DIR | --without-jre) [--out-dir DIR]\n' +
|
|
'Packages the server JAR and manifest, optionally with Java 21. Reuses an installed matching Qwen CLI.\n' +
|
|
'--without-jre builds a lite archive requiring local Java 21.\n' +
|
|
'Targets: darwin-arm64, darwin-x64, linux-arm64, linux-x64.\n' +
|
|
'Default output: packages/managed-agent-server/server/target/managed-runtime.',
|
|
);
|
|
} else {
|
|
for (const option of ['target', 'server-jar']) {
|
|
if (!values[option]) throw new Error(`--${option} is required.`);
|
|
}
|
|
if (Boolean(values['jre-home']) === Boolean(values['without-jre'])) {
|
|
throw new Error('Provide exactly one of --jre-home DIR or --without-jre.');
|
|
}
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const { version } = JSON.parse(
|
|
fs.readFileSync(path.join(root, 'package.json'), 'utf8'),
|
|
);
|
|
const target = values.target;
|
|
const outDir = path.resolve(
|
|
values['out-dir'] ??
|
|
path.join(
|
|
root,
|
|
'packages',
|
|
'managed-agent-server',
|
|
'server',
|
|
'target',
|
|
'managed-runtime',
|
|
),
|
|
);
|
|
const temporary = fs.mkdtempSync(
|
|
path.join(os.tmpdir(), 'qwen-managed-runtime-'),
|
|
);
|
|
try {
|
|
copyManagedLocalRuntime({
|
|
destination: path.join(temporary, 'managed-runtime', version, target),
|
|
serverJar: path.resolve(values['server-jar']),
|
|
jreHome: values['jre-home']
|
|
? path.resolve(values['jre-home'])
|
|
: undefined,
|
|
version,
|
|
target,
|
|
runtime: 'node',
|
|
});
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
const name = `qwen-code-managed-runtime-${values['without-jre'] ? 'lite-' : ''}${target}.tar.gz`;
|
|
const archive = path.join(outDir, name);
|
|
execFileSync('tar', ['-czf', archive, '-C', temporary, 'managed-runtime'], {
|
|
stdio: 'inherit',
|
|
env: { ...process.env, COPYFILE_DISABLE: '1' },
|
|
});
|
|
const digest = createHash('sha256');
|
|
for await (const chunk of fs.createReadStream(archive))
|
|
digest.update(chunk);
|
|
fs.writeFileSync(`${archive}.sha256`, `${digest.digest('hex')} ${name}\n`);
|
|
console.log(`Created ${archive}\nCreated ${archive}.sha256`);
|
|
} finally {
|
|
fs.rmSync(temporary, { recursive: true, force: true });
|
|
}
|
|
}
|