davidgereb/dsh-lib-context-injection ↗★ 0
dsh-lib-context-injection
适用于 DSH Web 插件的共享智能体上下文注入助手库。提供后续消息注入、模型选择恢复等功能,用于定时发送、简易门禁及崩溃重启恢复。
AI 分析
核心用途是为 DSH 插件开发者提供上下文注入和会话恢复的共享工具函数。适合 DSH 插件开发者,作为 cost-lens 或 watchdog 等插件的底层依赖自动安装,普通用户无需手动安装。
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗Usage
import { deriveModelSelection, injectUserMessage, ensureModelSelection } from "dsh-lib-context-injection";
// wake an agent with a plugin-tagged follow-up
injectUserMessage(agent, { text: "Continue where you left off.", plugin: "my-plugin" });
// restore the session's model route on a headless/resumed agent
ensureModelSelection(agent, agent.session?.events ?? [], {
fallbackProvider: "deepseek",
fallbackModel: "deepseek-v4-flash",
logger: ctx.logger,
plugin: "my-plugin"
});
Cordis scoped-context note. The resume
setup(agentCtx)callback passes a Cordis scoped-context proxy; reading a non-injected property on it (e.g.agentCtx.ctx) throwscannot get property "ctx" without inject.installModelSelectionOn/ensureModelSelectionhandle this: they probetarget.ctxin a guarded try/catch and fall back to using the raw context itself — the same as the pre-library callers did.