davidgereb/dsh-lib-context-injection ↗★ 0
dsh-lib-context-injection
Shared agent context-injection helpers for dsh web plugins: follow-up message injection (agent.followup) and model-selection restoration (installModelSelection) for scheduled sends, cheapass gating, and crash/restart resume
AI 분석
核心用途是为 DSH 插件开发者提供上下文注入和会话恢复的共享工具函数。适合 DSH 插件开发者,作为 cost-lens 或 watchdog 等插件的底层依赖自动安装,普通用户无需手动安装。
설치
검증된 bundle이 없거나 호환성 검사에 실패했습니다. 먼저 저장소 설명을 읽어 주세요. 전체 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.