Skip to content

Commit a82f509

Browse files
steipetePeter Steinberger
andauthored
feat: user-installed provider plugins with TypeScript support (#2642)
* feat: add user-installed provider plugins * fix: broker owns plugin HTTP representation headers Apply broker-owned Accept, Accept-Encoding, and Content-Type after plugin-supplied headers so a plugin cannot relax the user-plugin response boundary. Test transport gains configurable response headers. * build: add reproducible sucrase bundle verification script Regenerates and verifies Sources/CodexBarCore/Resources/Plugins/ sucrase-3.35.1.min.js from the official npm artifact (sucrase@3.35.1, esbuild@0.25.8 pinned, IIFE browser bundle). Expected SHA-256 4d997e15b72cbc9ccf6e743c30c6eb48bf4533f6709852367b40766be5eba70b was independently reproduced by the coordinator from the npm registry; 'check' mode fails closed on any mismatch. * fix: gate user-plugin registry lookup for non-JavaScriptCore platforms Linux CLI builds compile CodexBarConfig without the plugin runtime; unknown plugin config entries are dropped with the existing warning, matching the documented macOS-only plugin boundary. --------- Co-authored-by: Peter Steinberger <steipete@mac-studio-sf2.local>
1 parent 15a855a commit a82f509

28 files changed

Lines changed: 2375 additions & 45 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Sessions: discover live pi and OMP sessions through one Pi-family scanner, with dialect-aware metadata, PID-only startup rows, and mixed-version CLI/remote support (#2529). Thanks @wdmitchelluk!
99
- Kimi/GLM: distinguish Kimi Code from the regional Open Platform, bind China and international keys to their issuing hosts, and show GLM Coding Plan's 5-hour window as primary with MCP separate (#2351). Thanks @Leehow!
1010
- Provider plugins: declarative detail rows/charts plus bundled JavaScript conversions for OpenAI, z.ai, OpenRouter, Poe, and ClawRouter behind `CODEXBAR_JS_PROVIDERS=1`.
11+
- Provider plugins: install local JavaScript or TypeScript providers with manifest-driven settings and generic menu cards, approval-bound network/cookie access, and sandboxed Sucrase transpilation.
1112

1213
### Changed
1314
- Menu: move each usage window's used percentage and reset time into its title row, with all pace detail on one line (#2182). Thanks @jack24254029!
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
# Reproducibly regenerates Sources/CodexBarCore/Resources/Plugins/sucrase-3.35.1.min.js
3+
# from the official npm artifact. The vendored bundle MUST match EXPECTED_SHA256;
4+
# review of the minified blob is by reproduction, not by reading.
5+
set -euo pipefail
6+
7+
SUCRASE_VERSION="3.35.1"
8+
ESBUILD_VERSION="0.25.8"
9+
EXPECTED_SHA256="4d997e15b72cbc9ccf6e743c30c6eb48bf4533f6709852367b40766be5eba70b"
10+
11+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
12+
OUTPUT_FILE="${ROOT_DIR}/Sources/CodexBarCore/Resources/Plugins/sucrase-${SUCRASE_VERSION}.min.js"
13+
MODE="${1:-check}"
14+
15+
WORK_DIR="$(mktemp -d /tmp/codexbar-sucrase-regen.XXXXXX)"
16+
trap 'rm -rf "$WORK_DIR"' EXIT
17+
cd "$WORK_DIR"
18+
19+
npm init -y >/dev/null 2>&1
20+
npm install --ignore-scripts --no-audit --no-fund "sucrase@${SUCRASE_VERSION}" >/dev/null
21+
npx --yes "esbuild@${ESBUILD_VERSION}" node_modules/sucrase/dist/index.js \
22+
--bundle --minify --platform=browser --format=iife --global-name=sucrase \
23+
--banner:js="/*! Sucrase v${SUCRASE_VERSION} | MIT License | Copyright (c) 2012-present various contributors | https://github.com/alangpierce/sucrase */" \
24+
--outfile="${WORK_DIR}/sucrase.min.js" >/dev/null 2>&1
25+
26+
ACTUAL_SHA256="$(shasum -a 256 "${WORK_DIR}/sucrase.min.js" | awk '{print $1}')"
27+
if [[ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]]; then
28+
echo "error: reproduced bundle hash ${ACTUAL_SHA256} does not match expected ${EXPECTED_SHA256}" >&2
29+
echo "If the version or esbuild pin changed intentionally, update EXPECTED_SHA256." >&2
30+
exit 1
31+
fi
32+
33+
case "$MODE" in
34+
check | --check)
35+
VENDORED_SHA256="$(shasum -a 256 "$OUTPUT_FILE" | awk '{print $1}')"
36+
if [[ "$VENDORED_SHA256" != "$EXPECTED_SHA256" ]]; then
37+
echo "error: vendored bundle ${VENDORED_SHA256} does not match reproducible build ${EXPECTED_SHA256}" >&2
38+
exit 1
39+
fi
40+
echo "ok: vendored sucrase bundle matches reproducible build (${EXPECTED_SHA256})"
41+
;;
42+
write | --write)
43+
cp "${WORK_DIR}/sucrase.min.js" "$OUTPUT_FILE"
44+
echo "wrote ${OUTPUT_FILE} (${EXPECTED_SHA256})"
45+
;;
46+
*)
47+
echo "Usage: $0 [check|write]" >&2
48+
exit 2
49+
;;
50+
esac

0 commit comments

Comments
 (0)