feat: display upstream model maximums as read-only capacity facts

This commit is contained in:
Agent Workbench Dev
2026-11-06 09:31:24 +08:00
parent fda264e40a
commit 2a6554cdc8
7 changed files with 57 additions and 15 deletions
+5 -2
View File
@@ -18,7 +18,11 @@ export function packageSource({ root = process.cwd(), outputRoot = path.join(roo
const sourceCommit = git(['rev-parse', 'HEAD']).toString().trim();
const version = JSON.parse(git(['show', sourceCommit + ':package.json'])).version;
if (!/^\d+\.\d+\.\d+(?:-[a-z0-9.-]+)?$/i.test(version)) throw new Error('Invalid committed program version.');
const tree = git(['ls-tree', '-r', '--long', '-z', sourceCommit]).toString('utf8').split('\0').filter(Boolean).map(line => {
const selectedPaths = git(['ls-tree', '-r', '--name-only', '-z', sourceCommit]).toString('utf8').split('\0').filter(name =>
files.includes(name) || directories.some(directory => name.startsWith(directory + '/')) || guide(name));
const roots = [...directories.filter(name => selectedPaths.some(file => file.startsWith(name + '/'))),
...files.filter(name => selectedPaths.includes(name)), ...selectedPaths.filter(guide)];
const tree = git(['ls-tree', '-r', '--long', '-z', sourceCommit, '--', ...roots]).toString('utf8').split('\0').filter(Boolean).map(line => {
const match = /^(\d+) (\w+) ([a-f0-9]+)\s+(\d+|-)\t([\s\S]+)$/.exec(line);
if (!match) throw new Error('Invalid committed source entry.');
return { mode: match[1], type: match[2], gitBlob: match[3], bytes: Number(match[4]), path: match[5] };
@@ -26,7 +30,6 @@ export function packageSource({ root = process.cwd(), outputRoot = path.join(roo
const entries = tree.filter(row => files.includes(row.path) || directories.some(name => row.path.startsWith(name + '/')) || guide(row.path));
if (!entries.some(row => row.path === 'package-lock.json') || !entries.some(row => row.path.startsWith('src/'))) throw new Error('Committed source and dependency lock are required.');
if (entries.some(row => row.type !== 'blob' || !['100644', '100755'].includes(row.mode))) throw new Error('Source release requires regular committed files, without links or submodules.');
const roots = [...directories.filter(name => entries.some(row => row.path.startsWith(name + '/'))), ...files.filter(name => entries.some(row => row.path === name)), ...entries.filter(row => guide(row.path)).map(row => row.path)];
const name = `Agent-Workbench-${version}-source-code-${sourceCommit.slice(0, 8)}-${randomUUID()}`;
fs.mkdirSync(outputRoot, { recursive: true });
const archive = path.join(outputRoot, name + '.zip'), fd = fs.openSync(archive, 'wx');