henryZhouLikeStudy/dsh-lattice-adapter-command0

dsh-lattice-adapter-command

DSH Lattice V1 command adapter: safe shell:false execution with persistent or one-shot JSON-lines / JSON-RPC sessions, cancellation, timeouts and output limits.

AI 分析

核心用途是为 Lattice 体系提供安全的外部命令行进程执行通道,适合需要运行本地 Agent 服务、控制执行超时与输出边界的系统集成任务。

パッケージ
dsh-lattice-adapter-command
バージョン
0.1.0
ライセンス
Apache-2.0
最終更新
2026/08/14

インストール

検証済み bundle がないか、互換性チェックに失敗しています。先にリポジトリの説明を読んでください。 README 全文を読む ↗

ドキュメント

README 全文を読む ↗

Usage

One-shot

import { runOneShot } from "@dsh-lattice/adapter-command";

const result = await runOneShot({
  executable: process.execPath,
  args: ["-e", "console.log('hi')"],
  shell: false,
  mode: "one-shot",
  timeoutMs: 30_000,
  maxOutputBytes: 65_536,
});
// { exitCode: 0, stdout: "hi\n", timedOut: false, truncated: {...} }

Persistent JSON-RPC session

import { CommandSession } from "@dsh-lattice/adapter-command";

const session = new CommandSession({
  executable: "my-agent-server",
  args: ["--stdio"],
  shell: false,
  mode: "persistent",
  protocol: "jsonrpc",
});
session.start();
const result = await session.call("agent/turn", { prompt: "..." }, { timeoutMs: 60_000 });
session.close();

The session protocol speaks one JSON frame per line. jsonrpc frames conform to JSON-RPC 2.0; jsonl frames are { id, method, params }. A cancel notification ({ method: "cancel", params: { id } }) is sent when a call times out or is aborted, so cooperative servers can stop work.

CLI

dsh-lattice-command run --executable node --arg -e --arg "console.log('hi')"