qwen-code/scripts/create-managed-runtime-package.js
jinye c61044fae4
feat(managed-agent): Start daemon and Managed locally with one command (#14928)
* feat(managed-agent): add local serve and lightweight runtime packages

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* feat(managed-agent): download local server runtime on first use

Require local Java 21, install the exact-version service JAR atomically from OSS or GitHub, and reuse verified runtime caches offline. Add protected signed Central publication and identical release distribution without bundling Java in the CLI.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(ci): register managed runtime workflow size

Record the new release workflow in the repository size baseline so the static CI gate can track it.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* feat(managed-agent): Share the local daemon and Managed entry

Serve daemon APIs and the signed Managed proxy from one loopback listener. Keep workspace ownership explicit, enable authorized local directory import and preserve the daemon trust boundary.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): expose configured models in local Managed tasks

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(web-shell): Cover Managed and local deep-link restoration

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(managed-agent): Align local database expectation with main schema

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(managed): Keep local model and approval choices independent

Use native initial model selection for local model presets and persist it with the selected approval mode before admitting the first Turn. Preserve custom Agent definition policy pins and creation replay semantics.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-10-22 16:25:18 +00:00

86 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/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',
'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 });
}
}