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 分析

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

パッケージ
dsh-lib-context-injection
バージョン
0.1.1
ライセンス
MIT
最終更新
2026/08/16

インストール

検証済み 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) 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.