davidgereb/dsh-lib-context-injection0

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 Analysis

核心用途是为 DSH 插件开发者提供上下文注入和会话恢复的共享工具函数。适合 DSH 插件开发者,作为 cost-lens 或 watchdog 等插件的底层依赖自动安装,普通用户无需手动安装。

Package
dsh-lib-context-injection
Version
0.1.1
License
MIT
Last updated
Aug 16, 2026

Install

This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full 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) throws cannot get property "ctx" without inject. installModelSelectionOn/ensureModelSelection handle this: they probe target.ctx in a guarded try/catch and fall back to using the raw context itself — the same as the pre-library callers did.