Skip to content

agent-cteno 0.1.0: Cteno as a Magpie agent - #1248

Open
zalan159 wants to merge 1 commit into
magpie-community:mainfrom
zalan159:agent-cteno
Open

zalan159 wants to merge 1 commit into
magpie-community:mainfrom
zalan159:agent-cteno

Conversation

@zalan159

Copy link
Copy Markdown

Adds @magpie-community/agent-cteno: Cteno (cteno-host-cli and the Cteno desktop app) on Magpie's Agents page. Pick one of Magpie's models or routing groups in its row; switch it off and Cteno's profiles.json is put back. (Maintained by the Cteno team; also tracked upstream in yetone/magpie#5976.)

What it does

Cteno stores its model profiles in profiles.json inside its OS app-data folder (com.cteno-host.gui under ~/Library/Application Support, %APPDATA%, or $XDG_DATA_HOME / ~/.local/share, with $CTENO_APP_DATA_DIR override) as a profiles array plus default_profile_id. Because Magpie's moejs agent sandbox edits a single static path by dotted object keys, this package uses the same agent + Bun host companion (main) layout as @magpie-community/agent-zycode:

  • cteno.agent.js (moejs, zero imports): detects Cteno via bin: "cteno-host-cli" and dir: "~/.cteno", declares ua: ["cteno"] and an embedded SVG data: icon, and writes the selected model, gateway.v1, gateway.key (magpie-cteno), and model capabilities (context, output, images, thinking) to ~/.config/magpie-cteno/connection.json.
  • index.mjs + bridge.mjs (main, runs in Magpie's plugin host, zero dependencies, no network/process spawns): watches connection.json (plus synchronous process.once("exit", ...) flush on disable/unwire) and atomically updates only the id: "magpie" entry (api_format: "anthropic", picker_group: "Magpie") and default_profile_id: "magpie" in Cteno's profiles.json, keeping every user profile and top-level field (subscription_compress, light_model, media backends, base_url_schema) untouched.
  • Disconnect / disable / removal: restores profiles.json byte for byte when unmodified meanwhile (including CRLF and trailing-newline fidelity), or deletes profiles.json when created by the bridge and still empty of user profiles. If the user added or changed profiles in Cteno while connected, only id: "magpie" is removed and user edits (including a newly chosen default) stay.
  • Safety: refuses symlinks, non-regular files, invalid JSON, malformed profiles entries, and non-http(s) gateway URLs without touching user files; writes via mode-preserving wx temp file + renameSync, with 0600 recovery state.

Files: packages/cteno/{package.json,cteno.agent.js,index.mjs,bridge.mjs,cteno.test.mjs,README.md}, one row in README.md, and one registry.json entry ("kind": "agent").

Verification

  • HOME=$(mktemp -d) bun test packages/cteno: 10 pass, 0 fail (70 assertions).
  • HOME=$(mktemp -d) bun test scripts/: 40 pass, 0 fail.
  • bun scripts/check.mjs & bun scripts/bumped.mjs origin/main & npm pack --dry-run: pass (5.9 kB tarball, 5 files).
  • End-to-end verification against isolated Cteno (cteno-host-cli 2.11.8, sandbox HOME + CTENO_APP_DATA_DIR + CTENO_HOST_ROOT with an existing my-own user profile):
    1. Connect deepseek/deepseek-flash -> cteno-host-cli profile list reports defaultProfileId: "magpie", byokProfiles keeps my-own and adds magpie (pickerGroup: "Magpie", apiFormat: "anthropic", isCompressModel: true, thinking: true, baseUrl: "http://127.0.0.1:3425/v1").
    2. Disconnect -> cmp -s confirms profiles.json is restored byte for byte, and cteno-host-cli profile list reports defaultProfileId: "my-own" with only my-own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant