pine 0.1.0: Pine (pmndre/pine) on magpie's Agents page (#1038)
Adds @magpie-community/agent-pine 0.1.0: Pine (github.com/pmndre/pine) on magpie's Agents page. connect writes providers.magpie as one object in ~/.pine/models.json (gateway /v1, openai-responses, magpie's catalog); startup writes defaults.model in ~/.pine/pine.json as magpie/<id>; Library skills go to ~/.pine/skills. Same shape as agent-pig. Review (at da80445557bc2de93857e49451587e2ac28aef08): - Harm check: only packages/pine, the README Agents row and registry.json. No dependencies, install scripts, workflow changes, credential reads or new network hosts (the icon is Pine's logo on raw.githubusercontent.com). - Checked against Pine's source (pmndre/pine next, 738013c7): home defaults to $PINE_HOME or ~/.pine (src/cli.ts), models.json and pine.json live in the home, resolveModel splits a reference at the first "/" (src/agents.ts), an agent's own model overrides cfg.defaults.model, and <home>/skills is read for all agents (src/skills.ts). compat.supportsStrictMode is a pi-ai 1.5.2 key for openai-responses. - magpie applies the descriptor's prefix to startup.model (internal/agent/plugged.go), so pine.json gets magpie/<provider>/<model>. Run at the reviewed head on mote, HOME=$(mktemp -d): - packages/pine: bun test, 7 pass, 0 fail. - bun scripts/check.mjs: pass. - PR CI (pr, bumped) green after approving the first-time contributor's runs. Not tried: a real Pine daemon here (the author reports one answered through the gateway).
This commit is contained in:
@@ -297,6 +297,7 @@ it off puts the config back.
|
||||
| [minimax-design](packages/minimax-design) | [MiniMax Design](https://design.minimax.io), the local multimodal creation studio: one custom-model entry in `%APPDATA%\@hilo\desktop\hub-config.json` whose model menu follows magpie's list; Windows only |
|
||||
| [eta](packages/eta) | [Eta](https://github.com/Lingwcy/eta): connect-only local gateway integration; choose models and routing groups in Eta’s own picker after restarting. Requires Eta 0.1.164 or later |
|
||||
| [rhino9-ai](packages/rhino9-ai) | [Magpie-Rhino](https://github.com/mikidaren/Magpie-Rhino) for Rhino 9 on Windows, with Magpie models, custom groups and routing strategies through Rhino MCP. Install the companion `.yak`, restart Rhino once, then open its AI panel and choose **Magpie**; no command required |
|
||||
| [pine](packages/pine) | [Pine](https://github.com/pmndre/pine): magpie's endpoint and model catalog in `~/.pine/models.json`, and the model Pine starts on (`defaults.model` in `pine.json`) picked on the Agents page; restart Pine after a change |
|
||||
| [zycode](packages/zycode) | [zycode](https://github.com/zy1233/pi-python) (`zypi`, the VS Code extension, the ACP agent): Magpie's model in the `[model]` table of `~/.pi-python/agent.toml`, set by a host part that follows `local.env` and puts the file back byte for byte; restart zycode after choosing a model |
|
||||
| [meowcode](packages/meowcode) | [MeowCode](https://github.com/MuLiuSaMa/MeowCode): magpie's models in MeowCode's own model list, written to an overlay file beside its settings that MeowCode reads at start-up; restart MeowCode after choosing a model |
|
||||
| [lorca](packages/lorca) | [Lorca](https://lorca.app): `~/.lorca/credentials.json` as a custom provider, mirroring Magpie's models with thinking levels and MCP support via `~/.lorca/mcp.json` |
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
# @magpie-community/agent-pine
|
||||
|
||||
[Pine](https://github.com/pmndre/pine) as a magpie agent. Pine runs on pi's SDK, so it keeps its
|
||||
model servers in pi's file, `~/.pine/models.json`, and the model a new conversation starts on in
|
||||
`~/.pine/pine.json` as `defaults.model`. The plugin puts magpie's gateway there as the provider
|
||||
`magpie`, with magpie's whole catalog, and writes the model picked on magpie's Agents page into
|
||||
`pine.json`.
|
||||
|
||||
```sh
|
||||
magpie plugin add @magpie-community/agent-pine
|
||||
```
|
||||
|
||||
Then pick one of magpie's models in **Pine**'s row (or `magpie pine model magpie/<provider>/<model>`)
|
||||
and start a conversation: a new one starts on that model. `/model` in Pine still lists every
|
||||
magpie model and switches among them; a magpie model saved there keeps the row on magpie, and
|
||||
another provider's is yours and stays.
|
||||
|
||||
Switching Pine off, or `magpie pine default`, puts `defaults.model` back as it was (or takes it out
|
||||
where there was none) and takes the `magpie` provider out of `models.json`.
|
||||
|
||||
This needs a magpie with the Agent contract's `startup` field (v0.1.3008 or later); an older one
|
||||
reads this package as connect-only, and the model is picked with `/model` in Pine.
|
||||
|
||||
Pine is a project by pmndre. This is an unofficial integration, not affiliated with or endorsed by
|
||||
pmndre; PiG and Pi users are served by their own packages.
|
||||
|
||||
## What it owns
|
||||
|
||||
Two places, each stashed before magpie's first write and put back on disconnect:
|
||||
|
||||
| File | Key |
|
||||
| --- | --- |
|
||||
| `~/.pine/models.json` | the provider object `providers.magpie` |
|
||||
| `~/.pine/pine.json` | `defaults.model` |
|
||||
|
||||
| `providers.magpie` field | Value |
|
||||
| --- | --- |
|
||||
| `name` | `Magpie` |
|
||||
| `baseUrl` | the gateway's `/v1` address |
|
||||
| `api` | `openai-responses` |
|
||||
| `apiKey` | the key magpie keeps for Pine (`magpie-pine` on loopback) |
|
||||
| `compat` | `supportsStrictMode: true` |
|
||||
| `models` | magpie's catalog, each as a `models.json` entry |
|
||||
|
||||
Every other provider in `models.json` and every other key in `pine.json` stays as it is, including
|
||||
edits made while connected. The provider is written as one whole object, so stepping out removes
|
||||
it rather than leaving an empty provider Pine can't read; a `models.json` magpie makes from nothing
|
||||
keeps an empty `providers` map, which Pine still needs filled with its own or another server.
|
||||
|
||||
### Model ids
|
||||
|
||||
Pine reads a model reference at the first `/`, so the id is prefixed once: the model written into
|
||||
`pine.json` is `magpie/deepseek/deepseek-chat` — provider `magpie`, holding magpie's model
|
||||
`deepseek/deepseek-chat`, which goes to the gateway as it is and is routed there.
|
||||
|
||||
Each entry keeps magpie's id (slashes and all), name, image input, the context window and output
|
||||
limit where magpie knows them, and the model's thinking levels: a model with `efforts` is marked as
|
||||
thinking, with `thinkingLevelMap` naming each of pi's levels and hiding the ones it doesn't take
|
||||
(`off` is sent as `none` where the model has it). Limits magpie doesn't know are left out rather
|
||||
than written as `0`, so pi applies its own defaults. Requests go on the Responses API, which magpie
|
||||
relays where the provider speaks it and translates for the rest.
|
||||
|
||||
## Things to know
|
||||
|
||||
- **Agents with a model of their own.** `~/.pine/agents/<id>/agent.json` overrides `defaults.model`,
|
||||
so an agent that names a model there doesn't follow magpie's row. Clear it (or set it to one of
|
||||
magpie's models) for that agent.
|
||||
- **Restart Pine** after changing the model in magpie: Pine's daemon reads `models.json` and
|
||||
`pine.json` when it starts.
|
||||
- **Default folder only.** The package targets `~/.pine`; Pine's `$PINE_HOME` and `--home` are not
|
||||
followed. For another folder, copy `pine.agent.js`, change `config`, `startup.config`, `dir` and
|
||||
`library.skills`, and install that file (`magpie plugin add /abs/path/pine.agent.js`).
|
||||
- **Thinking** stays Pine's: `defaults.thinking`, `thinking` in `agent.json`, or `/reasoning`.
|
||||
Magpie's Effort field is not shown for this agent.
|
||||
- **Library** gets Pine's home `skills/` folder, so skills ticked for Pine land there and every
|
||||
Pine agent sees them. Instructions and MCP servers are not wired: Pine keeps instructions per
|
||||
agent under `agents/<id>/`, and its MCP entries are its own shape.
|
||||
- **No sign-in**: requests carry the key magpie keeps for Pine, so usage is counted under `pine`.
|
||||
The package reads no credentials, runs nothing, and sets nothing else.
|
||||
- **Disconnect before uninstalling**; removing the plugin does not run Pine's disconnect.
|
||||
|
||||
## 中文
|
||||
|
||||
Pine 跑在 pi 的 SDK 上:provider 在 `~/.pine/models.json`,新对话的起始模型在 `~/.pine/pine.json`
|
||||
的 `defaults.model`。装上后经 magpie 的网关用它,在 Agents 页 **Pine** 一行选 magpie 的模型即可,
|
||||
`/model` 仍可在 Pine 里切换。
|
||||
|
||||
magpie 只写两处:`providers.magpie`(网关地址、`magpie-pine` 钥匙、模型目录)和
|
||||
`defaults.model`;断开时各自还原,其余 provider 和键不动。模型写成 `magpie/<provider>/<model>`:
|
||||
Pine 只在第一个 `/` 处切分,provider 是 `magpie`,模型 id 就是 magpie 原来的
|
||||
`<provider>/<model>`,原样送到网关。
|
||||
|
||||
注意:`agents/<id>/agent.json` 里自己写的 `model` 优先,那个 agent 不跟着 magpie 走;换完模型要
|
||||
重启 Pine;只认默认的 `~/.pine`(用 `$PINE_HOME` 请复制描述文件改路径);思考等级由 Pine 自己管;
|
||||
`~/.pine/skills` 已接进 Library,指令与 MCP 未接;先断开再卸载。需要 magpie v0.1.3008 及以后,
|
||||
更早的版本当作 connect-only。非官方适配,与 pmndre 无关。
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@magpie-community/agent-pine",
|
||||
"version": "0.1.0",
|
||||
"description": "Pine (github.com/pmndre/pine) as a magpie agent: magpie's gateway and model catalog in ~/.pine/models.json, and the model Pine starts on in ~/.pine/pine.json",
|
||||
"type": "module",
|
||||
"files": ["pine.agent.js", "README.md"],
|
||||
"keywords": ["magpie", "magpie-agent", "pine", "pmndre", "llm-gateway"],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/magpie-community/plugins.git",
|
||||
"directory": "packages/pine"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "bun test pine.test.mjs"
|
||||
},
|
||||
"magpie": {
|
||||
"agent": "./pine.agent.js",
|
||||
"icon": "https://raw.githubusercontent.com/pmndre/pine/next/docs/images/logo-light.svg"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// Pine (github.com/pmndre/pine) runs on pi's SDK, so it keeps its model servers
|
||||
// in pi's own file, ~/.pine/models.json, and the model a new session starts on
|
||||
// in ~/.pine/pine.json as defaults.model, written "provider/model-id".
|
||||
//
|
||||
// magpie therefore writes the gateway as one provider, "magpie", in models.json,
|
||||
// and the model it picked into pine.json. Pine reads a reference at the first
|
||||
// "/", so magpie's model id "deepseek/deepseek-chat" is the model id inside the
|
||||
// provider "magpie" — exactly the id the gateway answers to.
|
||||
//
|
||||
// An agent that names a model of its own in agents/<id>/agent.json overrides
|
||||
// defaults.model; /model in Pine writes there. Magpie's row is the default, not
|
||||
// that agent's own choice.
|
||||
export const agent = {
|
||||
id: "pine",
|
||||
name: "Pine",
|
||||
// Pine's own logo from its repository (MIT), as the project shows it
|
||||
icon: "https://raw.githubusercontent.com/pmndre/pine/next/docs/images/logo-light.svg",
|
||||
bin: "pine",
|
||||
dir: "~/.pine",
|
||||
config: "~/.pine/models.json",
|
||||
format: "json",
|
||||
prefix: "magpie/",
|
||||
// the model a new session starts on, kept apart from connect's providers
|
||||
startup: {
|
||||
config: "~/.pine/pine.json",
|
||||
format: "json",
|
||||
model: "defaults.model",
|
||||
},
|
||||
// pine gives every agent the skills in its home's skills/ folder
|
||||
library: { skills: "~/.pine/skills" },
|
||||
notice: "New Pine conversations start on this model; /model in Pine still switches, and restarting Pine makes the daemon read the new provider. 新开的对话用这个模型;Pine 里的 /model 仍可切换;重启 pine 让守护进程读到新的 provider。",
|
||||
}
|
||||
|
||||
// pi's thinking levels, lowest first
|
||||
const LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"]
|
||||
|
||||
// one of magpie's models as an entry of pi's models.json
|
||||
function modelEntry(model) {
|
||||
const efforts = model.efforts ?? []
|
||||
const entry = {
|
||||
id: model.id,
|
||||
name: model.name || model.id,
|
||||
input: model.images ? ["text", "image"] : ["text"],
|
||||
// pi offers its thinking levels for a model that reasons only; the map
|
||||
// then says which level is sent as which, and hides the others
|
||||
reasoning: efforts.length > 0,
|
||||
}
|
||||
// unknown limits are left out, never written as 0: pi would take the model
|
||||
// for a 128K one and cap every reply at 16384 tokens
|
||||
if (model.context > 0) entry.contextWindow = model.context
|
||||
if (model.output > 0) entry.maxTokens = model.context > 0 ? Math.min(model.output, model.context) : model.output
|
||||
if (entry.reasoning) {
|
||||
entry.thinkingLevelMap = {}
|
||||
for (const level of LEVELS) {
|
||||
const sent = level === "off" ? "none" : level
|
||||
entry.thinkingLevelMap[level] = efforts.includes(sent) ? sent : null
|
||||
}
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
export function connect({ gateway, models }) {
|
||||
// one object, so magpie stashes and puts back the whole provider: written
|
||||
// leaf by leaf, stepping out would leave an empty provider where there was
|
||||
// no provider before, and Pine would fail to read it
|
||||
return {
|
||||
"providers.magpie": {
|
||||
name: "Magpie",
|
||||
baseUrl: gateway.v1,
|
||||
// the gateway translates for a provider that speaks another API
|
||||
api: "openai-responses",
|
||||
apiKey: gateway.key,
|
||||
// a function tool left without "strict" is taken for a strict-mode schema
|
||||
// by OpenAI's Responses API; pi-ai says strict: false there only when
|
||||
// the compat asks it to
|
||||
compat: { supportsStrictMode: true },
|
||||
models: models.map(modelEntry),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { agent, connect } from "./pine.agent.js"
|
||||
|
||||
const gateway = { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-pine" }
|
||||
|
||||
test("says where Pine keeps its providers and the model it starts on", () => {
|
||||
expect(agent).toMatchObject({
|
||||
id: "pine",
|
||||
bin: "pine",
|
||||
dir: "~/.pine",
|
||||
config: "~/.pine/models.json",
|
||||
prefix: "magpie/",
|
||||
startup: { config: "~/.pine/pine.json", model: "defaults.model" },
|
||||
library: { skills: "~/.pine/skills" },
|
||||
})
|
||||
})
|
||||
|
||||
test("is the package the Agents page loads, with Pine's own icon", async () => {
|
||||
const pkg = await Bun.file(new URL("./package.json", import.meta.url)).json()
|
||||
expect(pkg.magpie.agent).toBe("./pine.agent.js")
|
||||
expect(pkg.magpie.icon).toBe(agent.icon)
|
||||
expect(pkg.files).toContain("pine.agent.js")
|
||||
})
|
||||
|
||||
test("writes the gateway as one provider object, not as leaf keys", () => {
|
||||
const out = connect({ gateway, models: [] })
|
||||
expect(Object.keys(out)).toEqual(["providers.magpie"])
|
||||
expect(out["providers.magpie"]).toMatchObject({
|
||||
name: "Magpie",
|
||||
baseUrl: gateway.v1,
|
||||
api: "openai-responses",
|
||||
apiKey: gateway.key,
|
||||
compat: { supportsStrictMode: true },
|
||||
})
|
||||
})
|
||||
|
||||
test("lists magpie's models by the id the gateway answers to", () => {
|
||||
const out = connect({
|
||||
gateway,
|
||||
models: [
|
||||
{ id: "deepseek/deepseek-chat", name: "DeepSeek Chat", context: 1000000, output: 8192, images: false, efforts: [] },
|
||||
{ id: "anthropic/claude-sonnet-4-5", name: "", context: 200000, output: 64000, images: true, efforts: ["low", "medium", "high"] },
|
||||
{ id: "unknown/model", name: "Unknown", context: 0, output: 0, images: false },
|
||||
],
|
||||
})
|
||||
expect(out["providers.magpie"].models).toEqual([
|
||||
{
|
||||
id: "deepseek/deepseek-chat",
|
||||
name: "DeepSeek Chat",
|
||||
input: ["text"],
|
||||
reasoning: false,
|
||||
contextWindow: 1000000,
|
||||
maxTokens: 8192,
|
||||
},
|
||||
{
|
||||
id: "anthropic/claude-sonnet-4-5",
|
||||
name: "anthropic/claude-sonnet-4-5",
|
||||
input: ["text", "image"],
|
||||
reasoning: true,
|
||||
contextWindow: 200000,
|
||||
// a known output limit is capped at the window it comes out of
|
||||
maxTokens: 64000,
|
||||
thinkingLevelMap: { off: null, minimal: null, low: "low", medium: "medium", high: "high", xhigh: null, max: null },
|
||||
},
|
||||
// limits the catalog does not know are left out, never 0
|
||||
{ id: "unknown/model", name: "Unknown", input: ["text"], reasoning: false },
|
||||
])
|
||||
})
|
||||
|
||||
test("caps an output limit above the model's window", () => {
|
||||
const out = connect({ gateway, models: [{ id: "x/y", context: 32768, output: 65536, efforts: [] }] })
|
||||
expect(out["providers.magpie"].models[0].maxTokens).toBe(32768)
|
||||
})
|
||||
|
||||
test("keeps a model without efforts out of pi's thinking levels", () => {
|
||||
const out = connect({ gateway, models: [{ id: "x/y", efforts: [] }] })
|
||||
expect(out["providers.magpie"].models[0].reasoning).toBe(false)
|
||||
expect(out["providers.magpie"].models[0].thinkingLevelMap).toBeUndefined()
|
||||
})
|
||||
|
||||
test("off maps to none only where the model takes it", () => {
|
||||
const out = connect({ gateway, models: [{ id: "x/y", efforts: ["none", "high"] }] })
|
||||
expect(out["providers.magpie"].models[0].thinkingLevelMap).toEqual({
|
||||
off: "none",
|
||||
minimal: null,
|
||||
low: null,
|
||||
medium: null,
|
||||
high: "high",
|
||||
xhigh: null,
|
||||
max: null,
|
||||
})
|
||||
})
|
||||
+4
-1
@@ -301,6 +301,9 @@
|
||||
{ "package": "@magpie-community/agent-meowcode", "name": "MeowCode", "kind": "agent", "community": true, "summary": {"en": "MeowCode on magpie's Agents page: magpie's models appear in MeowCode's own model list, written to an overlay file MeowCode reads at start-up. Restart MeowCode after choosing a model.", "zh": "把 MeowCode 加到 magpie 的 Agent 页:magpie 的模型出现在 MeowCode 自己的模型列表里(启动时读取的覆盖层文件)。选择模型后需重启 MeowCode。"}},
|
||||
{ "package": "@magpie-community/agent-lorca", "name": "Lorca", "kind": "agent", "community": true, "icon": "https://lorca.app/icon.png", "summary": {"en": "Lorca on magpie's Agents page: writes Magpie's gateway, models and MCP servers into Lorca's credentials (~/.lorca/credentials.json). Restart Lorca after connecting.", "zh": "把 Lorca 加到 magpie 的 Agent 页:将 Magpie 的网关、模型目录与 MCP 工具库写入 Lorca 的凭据配置(~/.lorca/credentials.json)。连接后需重启 Lorca。"}},
|
||||
{ "package": "magpie-dafeiyu", "name": "DaFeiYu Desktop Pet", "kind": "page",
|
||||
"summary": { "en": "A guide page for DaFeiYu, a desktop pet that lights a bulb per request and shows quota percentages and API balances. The pet is a separate Windows/macOS app you download yourself; this page does not install or start it. Artwork from PC2005-cloud/dsh-pet, non-commercial use only.", "zh": "蓝色大肥鱼桌宠的使用指南页:几个请求亮几盏灯,订阅显示额度百分比,API 钱包显示余额。桌宠是需要另外下载的 Windows/macOS 独立 App,本页不会安装或启动它。角色素材来自 PC2005-cloud/dsh-pet,仅限非商用。" } }
|
||||
"summary": { "en": "A guide page for DaFeiYu, a desktop pet that lights a bulb per request and shows quota percentages and API balances. The pet is a separate Windows/macOS app you download yourself; this page does not install or start it. Artwork from PC2005-cloud/dsh-pet, non-commercial use only.", "zh": "蓝色大肥鱼桌宠的使用指南页:几个请求亮几盏灯,订阅显示额度百分比,API 钱包显示余额。桌宠是需要另外下载的 Windows/macOS 独立 App,本页不会安装或启动它。角色素材来自 PC2005-cloud/dsh-pet,仅限非商用。" } },
|
||||
{ "package": "@magpie-community/agent-pine", "name": "Pine", "kind": "agent", "community": true,
|
||||
"icon": "https://raw.githubusercontent.com/pmndre/pine/next/docs/images/logo-light.svg",
|
||||
"summary": { "en": "Pine (pmndre/pine, the event-driven agent harness on pi's SDK) on magpie's Agents page: pick one of magpie's models and magpie writes its gateway and catalog into ~/.pine/models.json and the model into pine.json, so new conversations start on it. Restart Pine after a change; unofficial.", "zh": "把 Pine(pmndre/pine,跑在 pi SDK 上的事件驱动 Agent 框架)加到 magpie 的 Agent 页:选一个 magpie 的模型,magpie 把网关和模型目录写进 ~/.pine/models.json、把起始模型写进 pine.json,新对话就用它。换完模型要重启 Pine;非官方适配。" } }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user