@mstar-harness/dsh 3.5.1 → 3.6.0-alpha.2

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.
@@ -1,108 +0,0 @@
1
- /**
2
- * Role-based subagent decoration at the `subagent/start` seam (plan
3
- * `20260814-dsh-fallbacks-integration` Task 2).
4
- *
5
- * Decoration rides the `subagent/start` EMIT — NOT `tools/pre-execute`:
6
- * tool args are deep-frozen snapshots and persona/`agentOptions` come from
7
- * the tool-subagent's own Config, never call args. The listener is
8
- * SYNCHRONOUS (the section must register before the child's first LLM call)
9
- * and resolves the published child via `ctx.get('agents')?.get(info.id)` —
10
- * documented in the `@deepseek-ai/dsh-subagent` event contract ("For
11
- * in-process providers, `ctx.agents.get(info.id)` resolves during this
12
- * notification"). The registered section is agent-scoped on `Agent.ctx`
13
- * (contributions are agent-local and unwind on disposal — the
14
- * hooks-claude-code precedent).
15
- *
16
- * Role identity uses the engine Assignment header grammar — the SAME
17
- * parsers the dispatch gate uses (`assignmentHeaderRegion` +
18
- * `parseAssignmentFields`) — over the child's seeded task prompt (the
19
- * child session's first `user/message`). Persona lookup (plan
20
- * `20260815-dsh-fallbacks-personas` Task 3) is the single
21
- * {@link personaFor} surface — `Config.rolePersonas[executeAs]` →
22
- * `harness-agents/` mirror default → skip (never gated on `roleMap` or on
23
- * the fallbacks mounted state: unmounted fallbacks degrades to the same
24
- * injection with exactly one debug log; probe at the decision point, no
25
- * cache). `roleMap` is a taxonomy bridge for logging + future rule-driven
26
- * interop only. The mirror root is bound at apply (`setDecorationAgentsDir`
27
- * ← `packagedAgentsDir()`), package-relative so the shipped bundle works
28
- * from any launch cwd.
29
- *
30
- * Degradation (the listener never throws — contained like the dispatch
31
- * gate's degrade path): `agents` service absent → skip + one debug log
32
- * (documented Known Limitation for compositions without dsh-agent);
33
- * child unresolved / non-Assignment / role-unmatched → silent no-op
34
- * (role-unmatched with the mirror present and no eligible shell stays
35
- * silent; with NO mirror the config-miss path logs ONE debug per apply —
36
- * case (e) semantics). A throwing log sink is contained inside the log
37
- * helper itself (plan QC F-002) — the sink must not escape the listener
38
- * either.
39
- *
40
- * Persona text is rendered by dsh system-prompt's STRICT `{{...}}`
41
- * interpolation, so persona values MUST NOT contain `{{` paired with a
42
- * later `}}` — the Config schema rejects such values at plugin mount (see
43
- * `_shared.ts` `rolePersonas` / `PERSONA_INTERPOLATION_HAZARD`); a mirror
44
- * default carrying the hazard is warned + skipped at extraction (never a
45
- * boot throw).
46
- *
47
- * Module boundary: no barrel — the entry imports this module by explicit
48
- * relative path and re-exports the public names verbatim.
49
- */
50
- import type { Context } from '@deepseek-ai/cordis';
51
- import type { Config } from './_shared.ts';
52
- /** Logger label for the subagent decoration (dsh logger naming: `<scope>/<subject>`). */
53
- export declare const DECORATION_LOGGER = "mstar/subagent-decoration";
54
- /** The decoration's system-prompt section name (agent-scoped on `Agent.ctx`). */
55
- export declare const PERSONA_SECTION_NAME = "mstar:role-persona";
56
- /** Prompt order of the persona section — renders right after the deployment persona slot (order 0). */
57
- export declare const PERSONA_SECTION_ORDER = 1;
58
- /**
59
- * Structural view of the `subagent/start` emit payload the decoration
60
- * consumes (`@deepseek-ai/dsh-subagent` `SubagentRunInfo` — the plugin
61
- * carries no dsh-subagent dependency; same pattern as the probe's
62
- * `LoaderEntryView` and agent-flow's `TaskDoneSnapshot`). Only `id` is
63
- * consumed; the rest keeps the view faithful to the published contract.
64
- */
65
- export interface SubagentRunInfoView {
66
- /** Unique identity shared with the paired terminal event. */
67
- readonly runId: unknown;
68
- /** Provider name recorded when the child was first created. */
69
- readonly provider: string;
70
- /** The child agent's id. */
71
- readonly id: string;
72
- /** Snapshot of whether the run's local agent was present when start fulfilled. */
73
- readonly local: boolean;
74
- }
75
- /** Decoration log levels the module sink understands. */
76
- export type DecorationLogLevel = 'debug' | 'info' | 'warn';
77
- /** Module-level decoration log sink — bound by `apply` to `ctx.logger(DECORATION_LOGGER)` (agent-flow ledger precedent). */
78
- export type DecorationLogSink = (level: DecorationLogLevel, message: string) => void;
79
- /**
80
- * Bind the decoration log sink (the entry `apply` binds it to
81
- * `ctx.logger(DECORATION_LOGGER)`). Returns the PRIOR sink so a caller can
82
- * restore it (test pattern: agent-flow `setAgentFlowLogger`).
83
- */
84
- export declare function setDecorationLogger(sink: DecorationLogSink): DecorationLogSink;
85
- /**
86
- * Bind the persona-defaults mirror root. Returns the PRIOR binding so a
87
- * caller can restore it (test pattern: {@link setDecorationLogger}).
88
- * @param dir - the mirror root, or `undefined` to disable mirror defaults.
89
- */
90
- export declare function setDecorationAgentsDir(dir: string | undefined): string | undefined;
91
- /**
92
- * Decorate one `subagent/start` emit: resolve the child, extract its seeded
93
- * task prompt, and — when the prompt is Assignment-shaped and
94
- * `rolePersonas[executeAs]` is configured — register the persona as the
95
- * child's `mstar:role-persona` system-prompt section (agent-scoped on
96
- * `Agent.ctx`, unwinds on child disposal). Synchronous by design: the
97
- * section must register before the child's first LLM call.
98
- *
99
- * Never throws — every failure mode degrades (skip + one log line at most),
100
- * matching the dispatch gate's contained degrade path; the dispatch itself
101
- * is never affected.
102
- *
103
- * @param ctx - the plugin's registrant context (the app composition root).
104
- * @param config - validated plugin configuration (`rolePersonas` is the only
105
- * payload source; `roleMap` is never consulted for injection).
106
- * @param info - the `subagent/start` emit payload.
107
- */
108
- export declare function decorateSubagentStart(ctx: Context, config: Config, info: SubagentRunInfoView): void;