dsh-loop-engine 1.0.0-rc5 → 1.0.0-rc7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Kimi CLI process projection. The driver locates the `kimi` executable, builds
3
+ * the `-p --output-format stream-json` argv for one step, and projects the dsh
4
+ * subprocess seam handle onto a minimal transport the agent can read to
5
+ * completion. Kimi has no host permission callback and no `--tools` pruning
6
+ * flag in `-p` mode, so the whole child is spawned through the seam — the only
7
+ * available privilege boundary (the seam's OS sandbox, default read-only) — and
8
+ * every step is a fresh one-shot child because `-p` is inherently stateless.
9
+ *
10
+ * @module dsh-loop-engine/engine-kimi/process
11
+ */
12
+ import type { Readable, Writable } from 'node:stream';
13
+ import type { SubprocessHandle, SubprocessSpawnSpec } from '@deepseek-ai/dsh-subprocess';
14
+ /** The exact argv/cwd/env the driver requests for one `kimi -p` child. */
15
+ export interface KimiSpawnSpec {
16
+ /** The program plus its flags; `argv[0]` is the Kimi CLI executable. */
17
+ readonly argv: readonly string[];
18
+ readonly cwd: string;
19
+ readonly env: Record<string, string>;
20
+ /** Cancellation: the seam escalates process-tree termination when it fires. */
21
+ readonly signal?: AbortSignal;
22
+ }
23
+ /** A spawned Kimi process as the agent's transport needs it. */
24
+ export interface KimiProcess {
25
+ /** Child stdin (JSON-RPC request frames). */
26
+ readonly stdin: Writable;
27
+ /** Child stdout (the `session/update` notification frames). */
28
+ readonly stdout: Readable;
29
+ /** Child stderr (diagnostics; drained and dropped). */
30
+ readonly stderr: Readable;
31
+ /** Resolves when the child closes. */
32
+ readonly done: Promise<unknown>;
33
+ /** Request process-tree termination. */
34
+ terminate(): void;
35
+ }
36
+ /** Spawns one Kimi child over the given spec (the driver's spawn capability). */
37
+ export type KimiSpawnCapability = (spec: KimiSpawnSpec) => KimiProcess;
38
+ /** Resolve the Kimi home directory from `KIMI_CODE_HOME` or the current user's home. */
39
+ export declare function kimiHomeDir(): string;
40
+ /**
41
+ * Resolve the Kimi CLI executable. An explicit config path wins; otherwise this
42
+ * probes the standard `<kimi home>/bin/kimi[.exe]` location and falls back to
43
+ * `'kimi'` (resolved through PATH by the spawner).
44
+ * @param configBin - an operator-pinned absolute path (or `'kimi'`), if any.
45
+ * @returns the executable to spawn as `argv[0]`.
46
+ */
47
+ export declare function kimiBinResolver(configBin?: string): string;
48
+ /**
49
+ * Build the persistent `kimi acp` argv. The ACP child stays alive across steps
50
+ * and is spoken to over JSON-RPC on stdio — the prompt is a request body, not an
51
+ * argv positional — so there is no command-line length ceiling and no model flag
52
+ * (Kimi owns model selection natively via its own config).
53
+ * @param bin - the Kimi executable.
54
+ * @returns the argv, `argv[0]` being the executable.
55
+ */
56
+ export declare function kimiAcpArgv(bin: string): string[];
57
+ /** Project the driver's spawn request onto the dsh subprocess seam. */
58
+ export declare function kimiSubprocessSpec(spec: KimiSpawnSpec, graceMs: number): SubprocessSpawnSpec;
59
+ /** Project a dsh subprocess handle onto the Kimi process transport. */
60
+ export declare function fromSubprocess(handle: SubprocessHandle): KimiProcess;
61
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Kimi Code skill provider: exposes the Kimi CLI's instruction files and skills
3
+ * as DSH skills.
4
+ *
5
+ * Kimi reads per-directory `AGENTS.md` files from the session cwd up to the git
6
+ * root, and installs skills from `skills/` directories — the user-level
7
+ * `$KIMI_CODE_HOME/skills/` (default `~/.kimi-code/skills/`) and the
8
+ * project-level `.kimi-code/skills/` (walking up to the git root). Each
9
+ * context-file set is surfaced as one user-invocable `agents-md` skill whose
10
+ * body is the concatenated file contents; every found `SKILL.md` catalog entry
11
+ * is surfaced under its own name, so the dsh skill-injection seam (`/name`
12
+ * gestures) can carry them into the prompt.
13
+ *
14
+ * The generic `~/.agents/skills/` and `.agents/skills/` roots are deliberately
15
+ * not scanned here: dsh's own `skill-filesystem` provider already exposes them
16
+ * through the same registry in the web profile. Kimi built-in Skills are
17
+ * shipped inside the CLI and cannot be read from a stable on-disk location, so
18
+ * the filesystem subset above is authoritative for the web menu. Note the
19
+ * shared {@link parseSkillFile} mirrors the agents-skill frontmatter
20
+ * (`name`/`description`/`whenToUse`/`disable-model-invocation`); Kimi's own
21
+ * `disableModelInvocation`/`type` fields are not translated, so a `type: flow`
22
+ * skill is surfaced as model-invocable.
23
+ *
24
+ * @module dsh-loop-engine/engine-kimi/skills
25
+ */
26
+ import type { SkillCandidate, SkillDefinition, SkillLookupOptions, SkillProvider, SkillProviderControl } from '../skills.ts';
27
+ /**
28
+ * Resolve the Kimi config directory, honoring the `KIMI_CODE_HOME` environment
29
+ * override and falling back to `~/.kimi-code`.
30
+ * @returns the absolute Kimi config directory.
31
+ */
32
+ export declare function kimiAgentDir(): string;
33
+ /**
34
+ * Skill provider that discovers context files and skills from Kimi's standard
35
+ * locations:
36
+ * - project `AGENTS.md` files between the cwd and the git root — surfaced as
37
+ * one `agents-md` skill;
38
+ * - project `.kimi-code/skills/` and user `~/.kimi-code/skills/` — each
39
+ * `SKILL.md` entry surfaced under its own name.
40
+ */
41
+ export declare class KimiSkillProvider implements SkillProvider {
42
+ private readonly control;
43
+ readonly name = "kimi";
44
+ constructor(control: SkillProviderControl);
45
+ list(options: SkillLookupOptions): Promise<readonly SkillCandidate[]>;
46
+ get(candidate: SkillCandidate, _options: SkillLookupOptions): Promise<SkillDefinition | undefined>;
47
+ /** One merged `agents-md` candidate for a ranked file set. */
48
+ private agentsCandidate;
49
+ /** Collect every skill in one skills directory, both kimi layouts. */
50
+ private collectSkillsDir;
51
+ /** One parsed skill as a ranked candidate. */
52
+ private skillCandidate;
53
+ /** Parse one SKILL.md file, or `undefined` when it is unreadable or invalid. */
54
+ private tryParse;
55
+ }
56
+ export default KimiSkillProvider;
57
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Public types of the Kimi Code loop driver. Types only — no runtime code.
3
+ *
4
+ * Kimi Code (`kimi`) has no host approval callback ("runs with the permissions
5
+ * of the user"), and its non-interactive `-p` surface already auto-approves tool
6
+ * calls. It also exposes no `--tools` pruning flag in `-p` mode, so there is no
7
+ * per-driver permission lever to pin. The driver therefore spawns the whole
8
+ * `kimi -p` child through the dsh subprocess seam — the only available privilege
9
+ * boundary — and the sandbox stance follows the session's durable permission
10
+ * knobs as the subprocess provider resolves them (default read-only).
11
+ *
12
+ * @module dsh-loop-engine/engine-kimi/types
13
+ */
14
+ /** Driver configuration after defaults and load-time validation. */
15
+ export interface ResolvedConfig {
16
+ /** Model alias the `kimi` child is launched with (`--model`); Kimi native config owns the model when omitted. */
17
+ readonly model: string | undefined;
18
+ /** Explicit environment entries layered over the credential-scrubbed parent environment. */
19
+ readonly env: Record<string, string>;
20
+ /** Kimi CLI executable; `'kimi'` resolves through PATH when not pinned to an absolute path. */
21
+ readonly bin: string;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Web-switchable agent loop engine, node half.
3
3
  *
4
- * Hosts the non-default agent-loop engines (Claude Code, Codex) and
5
- * bridges them with the harness's single AgentFactory slot. The engine is
4
+ * Hosts the non-default agent-loop engines (Claude Code, Codex, Pi, Kimi Code)
5
+ * and bridges them with the harness's single AgentFactory slot. The engine is
6
6
  * selected by the `agent-loop-engine` settings section; the selection is
7
7
  * realized by a managed block in the profile's `cordis.patch.yml` that
8
8
  * disables the base bundle's `agent-loop` row — exactly one AgentFactory may
@@ -50,6 +50,8 @@ export interface Config extends ClaudeCodeConfig {
50
50
  piProvider?: string;
51
51
  /** Thinking/reasoning level for the Pi RPC child, appended to its `--model`. */
52
52
  piThinking?: string;
53
+ /** Kimi CLI executable; `'kimi'` resolves through PATH when not pinned to an absolute path. */
54
+ kimiBin?: string;
53
55
  }
54
56
  /**
55
57
  * Schema of the loop engine composition entry.
@@ -14,7 +14,7 @@ import z from '@deepseek-ai/schemastery';
14
14
  import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
15
15
  export { LOOP_ENGINE_SETTINGS_NAMESPACE_LITERAL } from './namespace.ts';
16
16
  /** The installed engine driving new Agent turns. */
17
- export declare const LOOP_ENGINE_IDS: readonly ["in-process", "claude-code", "codex", "pi"];
17
+ export declare const LOOP_ENGINE_IDS: readonly ["in-process", "claude-code", "codex", "pi", "kimi"];
18
18
  /** Installed agent loop engine id. */
19
19
  export type LoopEngineId = (typeof LOOP_ENGINE_IDS)[number];
20
20
  /** Stored and composed loop engine selection. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-loop-engine",
3
- "description": "Web-switchable agent loop engine selection for the DeepSeek Harness - out-of-tree plugin (Claude Code / Codex drivers) maintained by @kuun993, zero main-repo changes",
4
- "version": "1.0.0-rc5",
3
+ "description": "Web-switchable agent loop engine selection for the DeepSeek Harness - out-of-tree plugin (Claude Code / Codex / Pi / Kimi Code drivers) maintained by @kuun993, zero main-repo changes",
4
+ "version": "1.0.0-rc7",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },