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).
81 lines
3.4 KiB
JavaScript
81 lines
3.4 KiB
JavaScript
// 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),
|
|
},
|
|
}
|
|
}
|