dsh-agent-kit: DSH Plugin Toolkit for Resident Agent Worker

Introduction

When running “resident Agent Workers” in DeepSeek Harness (DSH), the business side often repeatedly implements the same set of cross-cutting capabilities: connecting upstream events via WebSocket, pushing alerts to IM, delegating semantic tasks to Claude Code or Codex, then filtering Agent outputs with low-cost validation. These logic is independent of specific protocols, routing, and business templates, yet almost every project needs to write it once.

@baoyx/dsh-agent-kit (community catalog entry byx-darwin/dsh-agent-kit) packages the above capabilities as a set of independently-enabled Cordis Services, with the business package only responsible for protocol, routing, templates, and workflows. Below is an introduction to its positioning, five Services, installation method, and typical usage in the README.

What Is This

  • Name: npm package @baoyx/dsh-agent-kit (repo byx-darwin/dsh-agent-kit), currently labeled as version 0.2.0 in the README, license MIT.
  • Maintainer: byx-darwin.
  • Category: “Workflow” in the SkillHub catalog.
  • One-liner: A DSH plugin toolkit for building resident Agent Workers — WebSocket access, DingTalk user push and notifications, Claude Code / Codex task delegation, TypeSafe Jev (or local Laya) validation.
  • Documentation: Official site https://byx-darwin.github.io/dsh-agent-kit/; historical design documents may contain removed approaches, defer to the current code and official site.

This package does not include business protocols, event types, prompts, or classification schemas, nor does it provide reliable event persistence; delivery reliability is handled by the peer. Only one Profile instance should be deployed per upstream WebSocket connection.

Two npm Packages

Package Purpose
@baoyx/dsh-agent-kit Library depended on by business packages: five Services and testing tools
@baoyx/dsh-agent-kit-admin (optional) Operations: dsh-agent-kit doctor / setup CLI, dsh Web “Settings → Agent Kit” page, business package settings entry registration

When the admin package is not installed, the five Services are still available, with configuration written in the Profile’s cordis.patch.yml.

Core Features: Five Services

The five Services are disabled by default and enabled on demand; disabled Services do not validate configuration and do not affect other Services. Each Service provides health(); entering failed state triggers the agent-kit/service-failed event. Errors are unified as KitError, with code and retryable.

Service Purpose
ctx.agentWs WebSocket client (only wss://): refreshable auth headers, heartbeat, exponential backoff reconnection, concurrency and backpressure; enters failed on auth failure or specified close code and supports slow retries
ctx.dingtalk Send messages as user via the logged-in DingTalk dws CLI; unified monitoring of group @ mentions, dispatch to business plugins by group ID / content rules; supports login status, device flow login and logout
ctx.notify Notification entry: business calls ctx.notify.send(), sent via DingTalk (depends on enabled ctx.dingtalk)
ctx.agentTasks Invoke dsh-registered subagent providers (e.g. claude-code, codex) to execute one-off tasks: default read-only permissions, independent task directory, JSON Schema typed output, concurrency and queue limits
ctx.jev Invoke TypeSafe Jev or local Laya, returning typed judgments of Choice / Noul / Score

The root entry @baoyx/dsh-agent-kit exports all Services, configurations, errors, and tools; additionally provides subpaths /ws, /dingtalk, /notify, /agent-tasks, /jev, /secrets, /testing.

Architecturally, business packages use the kit via inject, and the kit then depends on dsh’s subagent, subprocess, and Session; notify does not directly connect to external systems, it looks up dingtalk when sending and forwards.

Environment Requirements

  • Node.js ^22.19 or >=24
  • @deepseek-ai/dsh CLI 0.1.5-rc.3 or 0.1.7-alpha.2 (pre-release; cordis and other dependencies need to be locked with the dsh version used; examples below use 0.1.5-rc.3)
  • ctx.dingtalk: dws installed and logged in (README verified with dingtalk-workspace-cli@1.0.62), user identity only
  • ctx.agentTasks: install @deepseek-ai/dsh-subagent-claude-code and/or @deepseek-ai/dsh-subagent-codex, and complete native login
  • ctx.jev: install @typesafe-ai/sdk, set TYPESAFE_API_KEY; or configure provider: laya with baseURL
  • Production: Profile hosted by systemd, pm2, or other process daemons

This package does not automatically install dsh, dws, etc. at runtime; manual installation is possible, or through the admin package’s setup after confirmation.

Installation and Enablement

First set up global dsh and Profile, then add plugins per the README (do not construct github:owner/repo from the repo name).

npm i -g @deepseek-ai/dsh@0.1.5-rc.3

# Create a resident Profile based on the web template
dsh --profile my-agent --from-default-profile web

# This package, Agent providers, and business package (subagents must specify versions explicitly, latest may not match dsh)
dsh plugin --profile my-agent add @baoyx/dsh-agent-kit \
  @deepseek-ai/dsh-subagent-claude-code@0.1.5-rc.3 \
  @deepseek-ai/dsh-subagent-codex@0.1.5-rc.3
dsh plugin --profile my-agent add ./my-business-plugin-0.1.0.tgz

# Optional: operations tools
dsh plugin --profile my-agent add @baoyx/dsh-agent-kit-admin

# Enable the needed Services in cordis.patch.yml

dsh --profile my-agent --dump-config
dsh --profile my-agent --no-open

Business packages should declare the kit as peerDependencies to ensure only one instance is loaded within the Profile; @deepseek-ai/cordis version matches the target dsh (0.1.5-rc.3 corresponds to 4.0.2, 0.1.7-alpha.2 corresponds to 4.0.4).

Typical Usage

Business Plugin Skeleton

Plugins declare needed Services via inject, and in apply connect WebSocket, send notifications, run Agent tasks, and validate with Jev. Key points from the README example: WebSocket and Agent outputs are both treated as untrusted (untrusted(), business whitelist); alerts go through ctx.notify.send().

import type { Context } from '@deepseek-ai/cordis'
import { choice, isKitError, noul, untrusted } from '@baoyx/dsh-agent-kit'

export const name = 'my-agent'
export const inject = ['agentWs', 'notify', 'agentTasks', 'jev']

export function apply(ctx: Context, config: Config) {
  const conn = ctx.agentWs.connect<Frame>({
    url: config.url,
    headers: async () => ({ 'X-Token': await getToken() }),
    parse: parseFrame,
    concurrency: 2,
    onMessage: async (frame, { signal }) => {
      if (frame.type === 'alert') {
        await ctx.notify.send({
          title: frame.title,
          markdown: renderAlert(frame),
          idempotencyKey: frame.id,
          traceId: frame.id,
        })
        return
      }

      const draft = await ctx.agentTasks.run<Result>({
        provider: 'claude-code',
        title: `classify ${frame.id}`,
        prompt: [CLASSIFY_INSTRUCTIONS, untrusted('event', frame.input)],
        outputSchema: ResultSchema,
        signal,
        traceId: frame.id,
      })

      if (!CATEGORIES_ALLOWLIST.has(draft.output.category)) throw new Error('unexpected category')

      const { answers } = await ctx.jev.judge({
        state: { input: frame.input, candidate: draft.output },
        questions: {
          wrong: noul('候选结果与输入证据不符', { true: '不符', false: '相符' }),
          pick: choice('输入最符合哪个类别', CATEGORIES),
        },
        signal,
        traceId: frame.id,
      })

      await conn.send({ id: frame.id, result: draft.output, verified: answers.wrong.noul < 0.7 })
    },
    onError: (err, frame) => {
      if (isKitError(err) && err.retryable) {
        // Log and let peer retry delivery
      }
    },
  })
}

Notifications and DingTalk

For sending notifications, ctx.notify is recommended; when specifying a group, pass targets.dingtalk.chatId. When DingTalk is not ready, NotifyError (channel_unavailable).

await ctx.notify.send({
  title: '需要人工复核',
  markdown: body,
  targets: { dingtalk: { chatId: 'cidxxxx' } },
  idempotencyKey: frame.id,
})

For DingTalk login and group/user lookup, see the README “Notifications and DingTalk Login”; business plugins can register settings fields of kind: 'dingtalk-target', with the Web settings page assisting in selecting target IDs.

Use Cases and Notes

Who it’s for: Teams already running resident Profiles on DSH who need the pipeline of “WebSocket in → DingTalk alerts → delegate to subagent → Jev/Laya validation”, and want cross-cutting capabilities separated from business packages.

Please be aware before use:

  • Plugins run under the current dsh Profile process permissions and will invoke subprocesses (dws, Claude Code/Codex, etc.); before installation, read the GitHub source and the MIT license, and evaluate organizational compliance and key management yourself (the provider strips environment variables whose names contain KEY/TOKEN/SECRET/PASSWORD; when authentication is needed, configure explicitly in the provider Config’s env).
  • The DSH ecosystem is “everything is a plugin”; SkillHub is a community catalog, with no official affiliation with DeepSeek / High-Flyer.
  • The README indicates npm has published @baoyx/dsh-agent-kit and @baoyx/dsh-agent-kit-admin 0.2.0; the catalog page shows 0 stars, which does not represent feature completeness, defer to the documentation and versions.

Conclusion

dsh-agent-kit consolidates the four common cross-cutting capabilities of resident Agent Workers into five optional Services, allowing business packages to focus on protocols and workflows while reusing the same set of operations and monitoring hooks (health(), KitError, service-failed events).

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye