release: TradingAgents 1.0.0

TradingAgents: Towards Agentic Finance Research. See CHANGELOG.md for what 1.0.0 includes.
This commit is contained in:
Yijia-Xiao
2026-11-24 10:38:36 +00:00
parent 9fa1196fff
commit da95d501c9
437 changed files with 75470 additions and 30659 deletions
+60
View File
@@ -0,0 +1,60 @@
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
/** CHANGELOG.md as data: each version's items, newest first, and the module the build bundles. */
import type { VersionNotes } from "../src/cli/whats-new.js";
/**
* The versions in a changelog: each `## ` heading starts one (its version is the first thing on it, with
* or without brackets), each `### ` heading under it a group of its notes, and each `- ` line an item of the
* group it is in (items before any group are the version's own), continued by the indented lines after it.
*/
export function parseChangelog(text: string): VersionNotes[] {
const versions: VersionNotes[] = [];
for (const line of text.split(/\r?\n/)) {
const heading = /^##\s+\[?v?([^\]\s]+)\]?/.exec(line);
if (heading) {
versions.push({ version: heading[1] as string, sections: [] });
continue;
}
const current = versions.at(-1);
if (!current) continue;
const group = /^###\s+(.+)$/.exec(line);
if (group) {
current.sections.push({ heading: (group[1] as string).trim(), items: [] });
continue;
}
const item = /^-\s+(.*)$/.exec(line);
const section = current.sections.at(-1);
if (item) {
if (section) section.items.push((item[1] as string).trim());
else current.sections.push({ items: [(item[1] as string).trim()] });
} else if (/^\s+\S/.test(line) && section?.items.length) {
section.items[section.items.length - 1] += ` ${line.trim()}`;
}
}
return versions;
}
/** Version `version`'s section of a changelog as written, its heading left out; undefined when it has none. */
export function releaseNotes(text: string, version: string): string | undefined {
const lines = text.split(/\r?\n/);
const start = lines.findIndex((line) => /^##\s+\[?v?([^\]\s]+)\]?/.exec(line)?.[1] === version);
if (start < 0) return undefined;
const end = lines.findIndex((line, index) => index > start && /^##\s/.test(line));
return lines
.slice(start + 1, end < 0 ? undefined : end)
.join("\n")
.trim();
}
export function renderChangelog(versions: readonly VersionNotes[]): string {
return [
"// Copyright 2026 Tauric Research",
"// SPDX-License-Identifier: Apache-2.0",
"// Generated from CHANGELOG.md; do not edit.",
'import type { VersionNotes } from "./whats-new.js";',
"",
`export const CHANGELOG: readonly VersionNotes[] = ${JSON.stringify(versions, null, 2)};`,
"",
].join("\n");
}
+53
View File
@@ -0,0 +1,53 @@
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
/**
* Build the single-file executable from the compiled JavaScript in dist/. Run with Bun:
* `bun scripts/compile.ts [outfile] [target] [runtime]`, the target being one of Bun's (bun-darwin-arm64,
* ...); without one, the executable is for this machine. A cross-compiled executable is built on
* `runtime`, the target's Bun as scripts/runtime.ts checks it against package-lock.json; without one,
* Bun downloads the target's runtime itself.
*
* The executable reads no .env or bunfig.toml from the directory it runs in: its settings come only from
* its own environment and data directory.
*
* Ink imports react-devtools-core only when DEV=true and the package is installed, but the bundler hoists
* the import, so it resolves here to an empty module.
*/
const outfile = process.argv[2] ?? "dist-bin/tradingagents";
const target = process.argv[3] as Bun.Build.CompileTarget | undefined;
const executablePath = process.argv[4];
const result = await Bun.build({
entrypoints: ["dist/cli/main.js"],
minify: true,
// React's production build: its development build checks and warns as it renders.
define: { "process.env.NODE_ENV": '"production"' },
plugins: [
{
name: "no-react-devtools",
setup(build) {
build.onResolve({ filter: /^react-devtools-core$/ }, () => ({
path: "react-devtools-core",
namespace: "empty",
}));
build.onLoad({ filter: /.*/, namespace: "empty" }, () => ({
contents: "export default {};",
loader: "js",
}));
},
},
],
compile: {
outfile,
autoloadDotenv: false,
autoloadBunfig: false,
...(target ? { target } : {}),
...(executablePath ? { executablePath } : {}),
},
});
if (!result.success) {
for (const log of result.logs) console.error(log);
process.exit(1);
}
console.log(`compiled ${outfile}`);
+110
View File
@@ -0,0 +1,110 @@
#!/bin/sh
# Copyright 2026 Tauric Research
# SPDX-License-Identifier: Apache-2.0
# Install tradingagents for this machine.
#
# curl -fsSL https://tauric.ai/tradingagents/install.sh | sh the latest release
# curl -fsSL https://tauric.ai/tradingagents/install.sh | sh -s -- 1.2.3 a given release
#
# The latest release is the one GitHub marks latest. The download is checked against the release's
# SHA256SUMS and installed into TRADINGAGENTS_INSTALL_DIR (default ~/.local/bin). It runs as your own user and
# never asks for elevated rights.
#
# TRADINGAGENTS_RELEASE_URL (one release directory with tradingagents-<os>-<arch> and SHA256SUMS) reads the
# release from elsewhere.
set -euf
umask 022
fail() {
printf 'tradingagents install: %s\n' "$1" >&2
exit 1
}
releases=https://github.com/TauricResearch/TradingAgents/releases
[ "$#" -le 1 ] || fail "give at most one version"
pin=${1:-}
pin=${pin#v}
release=${TRADINGAGENTS_RELEASE_URL:-}
if [ -n "$pin" ]; then
printf '%s\n' "$pin" | grep -Eq '^(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})\.(0|[1-9][0-9]{0,8})$' ||
fail "$1 is not a version such as 1.2.3"
[ -z "$release" ] || fail "a version cannot be given with TRADINGAGENTS_RELEASE_URL"
release=$releases/download/v$pin
fi
release=${release:-$releases/latest/download}
case $release in
https://* | file://*) ;;
*) fail "the release URL must start with https:// or file://" ;;
esac
release=${release%/}
[ "$(id -u)" != 0 ] || fail "run this as your own user, not as root"
case $(uname -s) in
Linux) os=linux ;;
Darwin) os=darwin ;;
*) fail "$(uname -s) is not supported" ;;
esac
case $(uname -m) in
x86_64 | amd64) arch=x64 ;;
arm64 | aarch64) arch=arm64 ;;
*) fail "$(uname -m) processors are not supported" ;;
esac
if [ "$os" = linux ] && ldd --version 2>&1 | grep -qi musl; then
fail "Linux with musl (such as Alpine) is not supported; a glibc system is needed"
fi
name="tradingagents-$os-$arch"
command -v curl >/dev/null 2>&1 || fail "curl is needed"
if command -v sha256sum >/dev/null 2>&1; then
digest() { sha256sum "$1" | cut -d ' ' -f 1; }
elif command -v shasum >/dev/null 2>&1; then
digest() { shasum -a 256 "$1" | cut -d ' ' -f 1; }
else
fail "sha256sum or shasum is needed to check the download"
fi
if [ -n "${TRADINGAGENTS_INSTALL_DIR:-}" ]; then
dir=$TRADINGAGENTS_INSTALL_DIR
elif [ -n "${HOME:-}" ]; then
dir=$HOME/.local/bin
else
fail "HOME is not set; set TRADINGAGENTS_INSTALL_DIR to the directory to install into"
fi
work=$(mktemp -d)
partial="$dir/.tradingagents.$$"
trap 'rm -rf "$work" "$partial"' EXIT
# On a signal, exit so the EXIT trap cleans up.
trap 'exit 130' INT
trap 'exit 143' TERM
# https and local files only, after redirects too; the user's curl configuration is ignored. A third
# argument caps the size.
fetch() {
curl -q --fail --silent --show-error --location --proto '=https,file' --proto-redir '=https' \
--connect-timeout 20 --max-time 600 ${3:+--max-filesize "$3"} --output "$2" "$1" ||
fail "could not download $1"
}
fetch "$release/SHA256SUMS" "$work/SHA256SUMS"
fetch "$release/$name" "$work/$name"
# Exactly one well-formed line for this file.
expected=$(grep -E "^[0-9a-f]{64} $name\$" "$work/SHA256SUMS" | cut -d ' ' -f 1 || true)
[ -n "$expected" ] || fail "SHA256SUMS has no checksum for $name"
[ "$(printf '%s\n' "$expected" | wc -l | tr -d ' ')" = 1 ] || fail "SHA256SUMS has more than one checksum for $name"
[ "$(digest "$work/$name")" = "$expected" ] || fail "the download of $name does not match its checksum; nothing was installed"
# It must start here before it replaces anything, and goes into place in one step.
mkdir -p "$dir"
cp "$work/$name" "$partial"
chmod 755 "$partial"
version=$("$partial" --version 2>/dev/null) || fail "$name does not start on this system; nothing was installed"
[ -z "$pin" ] || [ "$version" = "$pin" ] || fail "the release for $pin says it is $version; nothing was installed"
mv -f "$partial" "$dir/tradingagents"
printf 'Installed tradingagents %s in %s\n' "$version" "$dir"
case :$PATH: in
*:"$dir":*) ;;
*) printf 'Add it to your PATH: export PATH="%s:$PATH"\n' "$dir" ;;
esac
+128
View File
@@ -0,0 +1,128 @@
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
/**
* The npm packages of a release, written from its executables: one package per platform under the @tauric
* scope, carrying that platform's executable, and @tauric/tradingagents, whose `tradingagents` command runs
* the one npm installed for the platform it is on. Every package has the release's version.
*
* bun scripts/npm-packages.ts <version> <directory with tradingagents-<os>-<arch>> <output directory>
*
* It writes <output>/tradingagents and <output>/tradingagents-<os>-<arch>, each ready for `npm publish`.
*/
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { join, resolve } from "node:path";
import {
NPM_PACKAGE,
NPM_PLATFORM_PREFIX,
NPM_UPDATE_COMMAND,
REPOSITORY_URL,
} from "../src/config/release.js";
const ROOT = resolve(import.meta.dirname, "..");
/** The licenses of the fonts the executable embeds for PDF reports. */
const FONT_DIR = join(ROOT, "licenses");
const FONT_LICENSES = ["OFL-EncodeSansExpanded.txt", "OFL-JetBrainsMono.txt"] as const;
/** The platforms a release is built for, as npm names their os and cpu. */
export const TARGETS = [
{ os: "darwin", cpu: "arm64" },
{ os: "darwin", cpu: "x64" },
{ os: "linux", cpu: "arm64" },
{ os: "linux", cpu: "x64" },
] as const;
const COMMON = {
license: "Apache-2.0",
homepage: REPOSITORY_URL,
repository: { type: "git", url: `git+${REPOSITORY_URL}.git` },
bugs: `${REPOSITORY_URL}/issues`,
};
/** The platform package's name for a target. */
export function platformPackage(target: { os: string; cpu: string }): string {
return `${NPM_PLATFORM_PREFIX}${target.os}-${target.cpu}`;
}
/** Write the packages for `version` from the executables in `from` into `out`; gives their directories. */
export function stagePackages(version: string, from: string, out: string): string[] {
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z.-]+)?$/.test(version)) {
throw new Error(`${version} is not a version`);
}
const license = readFileSync(join(ROOT, "LICENSE"));
// The executable carries the PDF report's fonts (scripts/gen-report-fonts.ts); their licenses go with it.
const fontLicenses = FONT_LICENSES.map((name) => ({
name,
text: readFileSync(join(FONT_DIR, name)),
}));
const written: string[] = [];
for (const target of TARGETS) {
const executable = join(from, `tradingagents-${target.os}-${target.cpu}`);
if (!existsSync(executable)) throw new Error(`${executable} is missing`);
const dir = join(out, `tradingagents-${target.os}-${target.cpu}`);
mkdirSync(join(dir, "bin"), { recursive: true });
copyFileSync(executable, join(dir, "bin", "tradingagents"));
chmodSync(join(dir, "bin", "tradingagents"), 0o755);
writeFileSync(join(dir, "LICENSE"), license);
mkdirSync(join(dir, "licenses"), { recursive: true });
for (const { name, text } of fontLicenses) writeFileSync(join(dir, "licenses", name), text);
writeJson(join(dir, "package.json"), {
name: platformPackage(target),
version,
description: `The TradingAgents executable for ${target.os === "darwin" ? "macOS" : "Linux"} on ${target.cpu}.`,
...COMMON,
os: [target.os],
cpu: [target.cpu],
// The Linux executables are built for glibc.
...(target.os === "linux" ? { libc: ["glibc"] } : {}),
files: ["bin", "licenses"],
publishConfig: { access: "public" },
});
written.push(dir);
}
const dir = join(out, "tradingagents");
mkdirSync(join(dir, "bin"), { recursive: true });
copyFileSync(join(ROOT, "scripts", "npm", "launcher.js"), join(dir, "bin", "tradingagents.js"));
chmodSync(join(dir, "bin", "tradingagents.js"), 0o755);
writeFileSync(join(dir, "LICENSE"), license);
writeFileSync(join(dir, "README.md"), README);
writeJson(join(dir, "package.json"), {
name: NPM_PACKAGE,
version,
description: "TradingAgents: Towards Agentic Finance Research",
...COMMON,
type: "module",
bin: { tradingagents: "bin/tradingagents.js" },
files: ["bin"],
engines: { node: ">=18" },
os: ["darwin", "linux"],
cpu: ["arm64", "x64"],
optionalDependencies: Object.fromEntries(TARGETS.map((target) => [platformPackage(target), version])),
publishConfig: { access: "public" },
});
return [...written, dir];
}
const README = `# TradingAgents: Towards Agentic Finance Research
\`\`\`bash
${NPM_UPDATE_COMMAND}
tradingagents
\`\`\`
Builds are for macOS and Linux (glibc), on x64 and arm64. See ${REPOSITORY_URL} for the documentation.
`;
function writeJson(path: string, value: unknown): void {
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
}
if (import.meta.main) {
const [version, from, out] = process.argv.slice(2);
if (!version || !from || !out) {
process.stderr.write(
"usage: bun scripts/npm-packages.ts <version> <executables directory> <output directory>\n",
);
process.exit(2);
}
for (const dir of stagePackages(version, from, out)) process.stdout.write(`${dir}\n`);
}
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env node
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
// The tradingagents command as npm installs it: it runs this platform's executable, from the package npm
// installed beside it for this platform, with the same arguments, and ends as that ends.
import { spawn } from "node:child_process";
import { createRequire } from "node:module";
import { dirname, join } from "node:path";
const TARGETS = ["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64"];
const target = `${process.platform}-${process.arch}`;
const reinstall = "npm i -g @tauric/tradingagents";
function fail(text) {
process.stderr.write(`tradingagents: ${text}\n`);
process.exit(1);
}
if (!TARGETS.includes(target)) {
fail(`there is no build for ${target}; builds are for macOS and Linux (glibc), on x64 and arm64.`);
}
const name = `@tauric/tradingagents-${target}`;
let executable;
try {
executable = join(
dirname(createRequire(import.meta.url).resolve(`${name}/package.json`)),
"bin",
"tradingagents",
);
} catch {
fail(
`${name} is not installed. npm installs it with this package unless optional dependencies are turned off; ` +
`on Linux it needs glibc. Reinstall with: ${reinstall}`,
);
}
const child = spawn(executable, process.argv.slice(2), { stdio: "inherit" });
// Ctrl+C reaches the executable from the terminal itself (it is in the same process group), so it is not
// passed on again; a signal sent to this process alone is.
const passOn = Object.fromEntries(["SIGTERM", "SIGHUP"].map((signal) => [signal, () => child.kill(signal)]));
const ignore = () => {};
process.on("SIGINT", ignore);
for (const [signal, handler] of Object.entries(passOn)) process.on(signal, handler);
child.on("error", (error) => fail(`could not start ${executable}: ${error.message}`));
child.on("exit", (code, signal) => {
process.off("SIGINT", ignore);
for (const [name, handler] of Object.entries(passOn)) process.off(name, handler);
// Ended by a signal: this process ends by the same one, so whoever waits on it sees how it ended.
if (signal) process.kill(process.pid, signal);
else process.exit(code ?? 1);
});
+13
View File
@@ -0,0 +1,13 @@
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
/** Print version `argv[2]`'s notes from CHANGELOG.md; fail when it has none. Run with Bun. */
import { readFileSync } from "node:fs";
import { releaseNotes } from "./changelog-source.ts";
const version = (process.argv[2] ?? "").replace(/^v/, "");
const notes = releaseNotes(readFileSync("CHANGELOG.md", "utf8"), version);
if (!notes) {
console.error(`CHANGELOG.md has no notes for ${version}`);
process.exit(1);
}
console.log(notes);
+57
View File
@@ -0,0 +1,57 @@
// Copyright 2026 Tauric Research
// SPDX-License-Identifier: Apache-2.0
/**
* The Bun runtime a cross-compiled executable is built on, as package-lock.json locks it: the target's
* package is downloaded from the address the lockfile records and refused unless its sha512 matches the
* lockfile's integrity. Run with Bun: `bun scripts/runtime.ts <target> <dir>`, the target being one of
* Bun's (bun-linux-x64, ...); it prints the path of the runtime it unpacked into <dir>.
*/
import { spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { REQUEST_MS } from "../src/contracts/limits.js";
/** Bun's compile targets, by the runtime package npm installs for each. */
const PACKAGES: Record<string, string> = {
"bun-linux-x64": "@oven/bun-linux-x64",
"bun-linux-arm64": "@oven/bun-linux-aarch64",
"bun-darwin-x64": "@oven/bun-darwin-x64",
"bun-darwin-arm64": "@oven/bun-darwin-aarch64",
};
type Lockfile = { packages: Record<string, { resolved?: string; integrity?: string } | undefined> };
/** Where the lockfile says the target's runtime package comes from, and what it must hash to. */
export function lockedRuntime(lock: Lockfile, target: string): { resolved: string; integrity: string } {
const name = PACKAGES[target];
if (!name) throw new Error(`no runtime package is known for the target ${target}`);
const entry = lock.packages[`node_modules/${name}`];
if (!entry?.resolved || !entry.integrity?.startsWith("sha512-")) {
throw new Error(`package-lock.json locks no sha512 for ${name}`);
}
return { resolved: entry.resolved, integrity: entry.integrity };
}
/** The integrity string of `bytes`, as npm writes it. */
export function integrityOf(bytes: Uint8Array): string {
return `sha512-${createHash("sha512").update(bytes).digest("base64")}`;
}
// Run directly by Bun, not when a test imports the functions above.
if ((import.meta as { main?: boolean }).main) {
const [target, dir] = process.argv.slice(2) as [string, string];
const lock = JSON.parse(readFileSync("package-lock.json", "utf8")) as Lockfile;
const { resolved, integrity } = lockedRuntime(lock, target);
const response = await fetch(resolved, { signal: AbortSignal.timeout(REQUEST_MS.runtimeDownload) });
if (!response.ok) throw new Error(`${resolved} answered ${response.status}`);
const bytes = new Uint8Array(await response.arrayBuffer());
if (integrityOf(bytes) !== integrity) throw new Error(`${resolved} does not match package-lock.json`);
const into = join(dir, target);
mkdirSync(into, { recursive: true });
const archive = join(into, "runtime.tgz");
writeFileSync(archive, bytes);
const unpacked = spawnSync("tar", ["-xzf", archive, "-C", into, "package/bin/bun"], { stdio: "inherit" });
if (unpacked.status !== 0) throw new Error(`could not unpack ${archive}`);
console.log(join(into, "package", "bin", "bun"));
}
+67
View File
@@ -0,0 +1,67 @@
#!/bin/sh
# Copyright 2026 Tauric Research
# SPDX-License-Identifier: Apache-2.0
# Checks a built executable as CI and the release workflow run it: sh scripts/smoke.sh <executable> <scratch dir>
#
# - it carries React's production build;
# - it prints its version and help, and answers one question (-p) from an OpenAI-compatible server, here a
# stub this script starts with Node;
# - it reads no .env or bunfig.toml where it runs (a loaded .env would turn sync on; a loaded bunfig.toml
# would print first).
set -eu
bin=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
scratch=$2
mkdir -p "$scratch"
if grep -aq _debugStack "$bin"; then
echo "the executable carries React's development build" >&2
exit 1
fi
"$bin" --version | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+'
"$bin" --help | grep -q 'tradingagents -p'
# A server that answers every chat request with one fixed sentence, streamed as chat completions are.
rm -f "$scratch/port"
node -e '
const reply = (res, chunk) => res.write(`data: ${JSON.stringify({ id: "s", object: "chat.completion.chunk", created: 0, model: "stub", ...chunk })}\n\n`);
const server = require("node:http").createServer((req, res) => {
req.resume();
req.on("end", () => {
if (req.method === "GET") return res.end(JSON.stringify({ object: "list", data: [{ id: "stub", object: "model" }] }));
res.writeHead(200, { "content-type": "text/event-stream" });
reply(res, { choices: [{ index: 0, delta: { role: "assistant", content: "The smoke answer." }, finish_reason: null }] });
reply(res, { choices: [{ index: 0, delta: {}, finish_reason: "stop" }], usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 } });
res.end("data: [DONE]\n\n");
});
});
server.listen(0, "127.0.0.1", () => require("node:fs").writeFileSync(process.argv[1], String(server.address().port)));
' "$scratch/port" &
stub=$!
trap 'kill "$stub" 2>/dev/null || true' EXIT
for _ in 1 2 3 4 5 6 7 8 9 10; do [ -s "$scratch/port" ] && break; sleep 1; done
answer=$(TRADINGAGENTS_HOME="$scratch/home" TRADINGAGENTS_BASE_URL="http://127.0.0.1:$(cat "$scratch/port")/v1" \
TRADINGAGENTS_MODEL=stub TRADINGAGENTS_SYNC=off TRADINGAGENTS_NO_UPDATE_CHECK=1 "$bin" -p "Say the smoke answer.")
case $answer in
*"The smoke answer."*) ;;
*)
printf '%s\n' "$answer" >&2
exit 1
;;
esac
dir="$scratch/cwd"
mkdir -p "$dir"
cd "$dir"
echo TRADINGAGENTS_SYNC=on >.env
echo 'preload = ["./preload.js"]' >bunfig.toml
echo 'console.log("preloaded")' >preload.js
out=$(TRADINGAGENTS_HOME="$dir/home" "$bin" sync status)
case $out in
"Sync is not set"*) ;;
*)
printf '%s\n' "$out" >&2
exit 1
;;
esac
echo "smoke: $bin"
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"allowImportingTsExtensions": true,
"types": ["bun"]
},
"include": ["."]
}