@kirkchinese/harness-forge 0.0.0-stage → 0.4.0

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.
Files changed (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -2
  3. package/assets/icon.svg +12 -0
  4. package/cordis.patch.yml +28 -0
  5. package/lib/agents/presets.d.ts +91 -0
  6. package/lib/agents/presets.js +282 -0
  7. package/lib/agents/profiles.d.ts +58 -0
  8. package/lib/agents/profiles.js +278 -0
  9. package/lib/agents/row.d.ts +17 -0
  10. package/lib/agents/row.js +146 -0
  11. package/lib/client/styles.d.ts +8 -0
  12. package/lib/client/styles.js +89 -0
  13. package/lib/client/typert.d.ts +14 -0
  14. package/lib/client/typert.js +110 -0
  15. package/lib/client.js +22500 -0
  16. package/lib/commands/definition.d.ts +40 -0
  17. package/lib/commands/definition.js +113 -0
  18. package/lib/commands/output-styles.d.ts +42 -0
  19. package/lib/commands/output-styles.js +152 -0
  20. package/lib/commands/row.d.ts +9 -0
  21. package/lib/commands/row.js +157 -0
  22. package/lib/context/instructions.d.ts +32 -0
  23. package/lib/context/instructions.js +88 -0
  24. package/lib/context/row.d.ts +16 -0
  25. package/lib/context/row.js +17 -0
  26. package/lib/dsh/commands.d.ts +30 -0
  27. package/lib/dsh/commands.js +61 -0
  28. package/lib/dsh/host.d.ts +107 -0
  29. package/lib/dsh/host.js +214 -0
  30. package/lib/dsh/model-route.d.ts +21 -0
  31. package/lib/dsh/model-route.js +37 -0
  32. package/lib/dsh/session-records.d.ts +78 -0
  33. package/lib/dsh/session-records.js +36 -0
  34. package/lib/dsh/subagents.d.ts +46 -0
  35. package/lib/dsh/subagents.js +14 -0
  36. package/lib/forge/contract.d.ts +231 -0
  37. package/lib/forge/contract.js +43 -0
  38. package/lib/forge/ledger.d.ts +143 -0
  39. package/lib/forge/ledger.js +733 -0
  40. package/lib/forge/live-mounts.d.ts +45 -0
  41. package/lib/forge/live-mounts.js +78 -0
  42. package/lib/forge/marketplace-install.d.ts +3 -0
  43. package/lib/forge/marketplace-install.js +64 -0
  44. package/lib/forge/npm.d.ts +31 -0
  45. package/lib/forge/npm.js +60 -0
  46. package/lib/forge/projects.d.ts +94 -0
  47. package/lib/forge/projects.js +336 -0
  48. package/lib/forge/receipts.d.ts +5 -0
  49. package/lib/forge/receipts.js +31 -0
  50. package/lib/forge/row.d.ts +32 -0
  51. package/lib/forge/row.js +59 -0
  52. package/lib/forge/service.d.ts +105 -0
  53. package/lib/forge/service.js +274 -0
  54. package/lib/forge/settings.d.ts +41 -0
  55. package/lib/forge/settings.js +115 -0
  56. package/lib/forge/state.d.ts +69 -0
  57. package/lib/forge/state.js +150 -0
  58. package/lib/forge/trust.d.ts +48 -0
  59. package/lib/forge/trust.js +107 -0
  60. package/lib/forge/turns.d.ts +13 -0
  61. package/lib/forge/turns.js +56 -0
  62. package/lib/hooks/broker/engine.d.ts +112 -0
  63. package/lib/hooks/broker/engine.js +728 -0
  64. package/lib/hooks/broker/helpers.d.ts +10 -0
  65. package/lib/hooks/broker/helpers.js +22 -0
  66. package/lib/hooks/broker/lifecycle.d.ts +65 -0
  67. package/lib/hooks/broker/lifecycle.js +342 -0
  68. package/lib/hooks/broker/session-events.d.ts +22 -0
  69. package/lib/hooks/broker/session-events.js +196 -0
  70. package/lib/hooks/broker/tools.d.ts +52 -0
  71. package/lib/hooks/broker/tools.js +424 -0
  72. package/lib/hooks/broker/types.d.ts +262 -0
  73. package/lib/hooks/broker/types.js +1 -0
  74. package/lib/hooks/broker.d.ts +80 -0
  75. package/lib/hooks/broker.js +95 -0
  76. package/lib/hooks/codex-user.d.ts +5 -0
  77. package/lib/hooks/codex-user.js +109 -0
  78. package/lib/hooks/condition.d.ts +11 -0
  79. package/lib/hooks/condition.js +181 -0
  80. package/lib/hooks/config.d.ts +85 -0
  81. package/lib/hooks/config.js +150 -0
  82. package/lib/hooks/matcher.d.ts +20 -0
  83. package/lib/hooks/matcher.js +39 -0
  84. package/lib/hooks/notice.d.ts +17 -0
  85. package/lib/hooks/notice.js +39 -0
  86. package/lib/hooks/output.d.ts +56 -0
  87. package/lib/hooks/output.js +214 -0
  88. package/lib/hooks/permissions.d.ts +14 -0
  89. package/lib/hooks/permissions.js +109 -0
  90. package/lib/hooks/process.d.ts +47 -0
  91. package/lib/hooks/process.js +134 -0
  92. package/lib/hooks/row.d.ts +17 -0
  93. package/lib/hooks/row.js +94 -0
  94. package/lib/hooks/runner.d.ts +85 -0
  95. package/lib/hooks/runner.js +293 -0
  96. package/lib/hooks/shell-commands.d.ts +19 -0
  97. package/lib/hooks/shell-commands.js +177 -0
  98. package/lib/hooks/shell.d.ts +43 -0
  99. package/lib/hooks/shell.js +126 -0
  100. package/lib/hooks/transcript.d.ts +28 -0
  101. package/lib/hooks/transcript.js +141 -0
  102. package/lib/hooks/vocabulary.d.ts +57 -0
  103. package/lib/hooks/vocabulary.js +364 -0
  104. package/lib/index.d.ts +31 -0
  105. package/lib/index.js +287 -0
  106. package/lib/mcp/auth.d.ts +35 -0
  107. package/lib/mcp/auth.js +178 -0
  108. package/lib/mcp/catalog.d.ts +36 -0
  109. package/lib/mcp/catalog.js +61 -0
  110. package/lib/mcp/mount.d.ts +75 -0
  111. package/lib/mcp/mount.js +217 -0
  112. package/lib/mcp/remote.d.ts +45 -0
  113. package/lib/mcp/remote.js +143 -0
  114. package/lib/mcp/row.d.ts +9 -0
  115. package/lib/mcp/row.js +131 -0
  116. package/lib/mods/bundler.d.ts +38 -0
  117. package/lib/mods/bundler.js +157 -0
  118. package/lib/mods/chain.d.ts +103 -0
  119. package/lib/mods/chain.js +436 -0
  120. package/lib/mods/claude.d.ts +27 -0
  121. package/lib/mods/claude.js +56 -0
  122. package/lib/mods/engine.d.ts +160 -0
  123. package/lib/mods/engine.js +701 -0
  124. package/lib/mods/expect.d.ts +8 -0
  125. package/lib/mods/expect.js +248 -0
  126. package/lib/mods/host.d.ts +105 -0
  127. package/lib/mods/host.js +462 -0
  128. package/lib/mods/loader.d.ts +53 -0
  129. package/lib/mods/loader.js +227 -0
  130. package/lib/mods/ops.d.ts +13 -0
  131. package/lib/mods/ops.js +117 -0
  132. package/lib/mods/row.d.ts +9 -0
  133. package/lib/mods/row.js +77 -0
  134. package/lib/mods/runtime.d.ts +60 -0
  135. package/lib/mods/runtime.js +133 -0
  136. package/lib/mods/service/commands.d.ts +17 -0
  137. package/lib/mods/service/commands.js +121 -0
  138. package/lib/mods/service/drawings.d.ts +36 -0
  139. package/lib/mods/service/drawings.js +64 -0
  140. package/lib/mods/service/sessions.d.ts +63 -0
  141. package/lib/mods/service/sessions.js +345 -0
  142. package/lib/mods/service/tools.d.ts +32 -0
  143. package/lib/mods/service/tools.js +253 -0
  144. package/lib/mods/service/turns.d.ts +32 -0
  145. package/lib/mods/service/turns.js +161 -0
  146. package/lib/mods/service/types.d.ts +151 -0
  147. package/lib/mods/service/types.js +1 -0
  148. package/lib/mods/service.d.ts +72 -0
  149. package/lib/mods/service.js +104 -0
  150. package/lib/mods/surfaces.d.ts +93 -0
  151. package/lib/mods/surfaces.js +309 -0
  152. package/lib/mods/values.d.ts +30 -0
  153. package/lib/mods/values.js +95 -0
  154. package/lib/opencode/bun.d.ts +40 -0
  155. package/lib/opencode/bun.js +156 -0
  156. package/lib/opencode/convert.d.ts +53 -0
  157. package/lib/opencode/convert.js +255 -0
  158. package/lib/opencode/row.d.ts +9 -0
  159. package/lib/opencode/row.js +86 -0
  160. package/lib/opencode/runtime/core.d.ts +74 -0
  161. package/lib/opencode/runtime/core.js +249 -0
  162. package/lib/opencode/runtime/events.d.ts +80 -0
  163. package/lib/opencode/runtime/events.js +281 -0
  164. package/lib/opencode/runtime/mount.d.ts +27 -0
  165. package/lib/opencode/runtime/mount.js +283 -0
  166. package/lib/opencode/runtime/server.d.ts +27 -0
  167. package/lib/opencode/runtime/server.js +353 -0
  168. package/lib/opencode/runtime/types.d.ts +109 -0
  169. package/lib/opencode/runtime/types.js +1 -0
  170. package/lib/opencode/runtime.d.ts +55 -0
  171. package/lib/opencode/runtime.js +79 -0
  172. package/lib/porting/port-gap.d.ts +30 -0
  173. package/lib/porting/port-gap.js +122 -0
  174. package/lib/porting/port-sessions.d.ts +41 -0
  175. package/lib/porting/port-sessions.js +98 -0
  176. package/lib/porting/prompt.d.ts +23 -0
  177. package/lib/porting/prompt.js +49 -0
  178. package/lib/porting/row.d.ts +16 -0
  179. package/lib/porting/row.js +25 -0
  180. package/lib/porting/verify-port.d.ts +53 -0
  181. package/lib/porting/verify-port.js +104 -0
  182. package/lib/presets/fs-search.d.ts +25 -0
  183. package/lib/presets/fs-search.js +17 -0
  184. package/lib/presets/tool-filter.d.ts +35 -0
  185. package/lib/presets/tool-filter.js +91 -0
  186. package/lib/sessions/claude.d.ts +29 -0
  187. package/lib/sessions/claude.js +83 -0
  188. package/lib/sessions/codex.d.ts +30 -0
  189. package/lib/sessions/codex.js +303 -0
  190. package/lib/sessions/opencode.d.ts +32 -0
  191. package/lib/sessions/opencode.js +320 -0
  192. package/lib/sessions/row.d.ts +14 -0
  193. package/lib/sessions/row.js +35 -0
  194. package/lib/shared/invocation.d.ts +169 -0
  195. package/lib/shared/invocation.js +325 -0
  196. package/lib/shared/render.d.ts +72 -0
  197. package/lib/shared/render.js +588 -0
  198. package/lib/shared/util.d.ts +21 -0
  199. package/lib/shared/util.js +32 -0
  200. package/lib/skills/bundled.d.ts +3 -0
  201. package/lib/skills/bundled.js +42 -0
  202. package/lib/skills/provider.d.ts +72 -0
  203. package/lib/skills/provider.js +340 -0
  204. package/lib/skills/row.d.ts +22 -0
  205. package/lib/skills/row.js +204 -0
  206. package/lib/workbench/adapter-coverage.d.ts +47 -0
  207. package/lib/workbench/adapter-coverage.js +102 -0
  208. package/lib/workbench/model-tools.d.ts +10 -0
  209. package/lib/workbench/model-tools.js +122 -0
  210. package/lib/workbench/overview.d.ts +103 -0
  211. package/lib/workbench/overview.js +159 -0
  212. package/lib/workbench/remote.d.ts +118 -0
  213. package/lib/workbench/remote.js +422 -0
  214. package/lib/workbench/row.d.ts +15 -0
  215. package/lib/workbench/row.js +16 -0
  216. package/lib/workbench/settings.d.ts +15 -0
  217. package/lib/workbench/settings.js +56 -0
  218. package/lib/workbench/workbench.d.ts +100 -0
  219. package/lib/workbench/workbench.js +260 -0
  220. package/locale/agents/en.json +6 -0
  221. package/locale/agents/zh.json +6 -0
  222. package/locale/commands/en.json +6 -0
  223. package/locale/commands/zh.json +6 -0
  224. package/locale/context/en.json +6 -0
  225. package/locale/context/zh.json +6 -0
  226. package/locale/en.json +6 -0
  227. package/locale/hooks/en.json +6 -0
  228. package/locale/hooks/zh.json +6 -0
  229. package/locale/mcp/en.json +6 -0
  230. package/locale/mcp/zh.json +6 -0
  231. package/locale/mods/en.json +6 -0
  232. package/locale/mods/zh.json +6 -0
  233. package/locale/opencode/en.json +6 -0
  234. package/locale/opencode/zh.json +6 -0
  235. package/locale/porter/en.json +6 -0
  236. package/locale/porter/zh.json +6 -0
  237. package/locale/sessions/en.json +6 -0
  238. package/locale/sessions/zh.json +6 -0
  239. package/locale/skills/en.json +6 -0
  240. package/locale/skills/zh.json +6 -0
  241. package/locale/workbench/en.json +6 -0
  242. package/locale/workbench/zh.json +6 -0
  243. package/locale/zh.json +6 -0
  244. package/package.json +246 -3
  245. package/runtime/opencode-host.mjs +270 -0
  246. package/skills/harness-forge/SKILL.md +47 -0
@@ -0,0 +1,278 @@
1
+ /**
2
+ * What an imported agent's frontmatter asks of each run of that agent,
3
+ * beyond its persona and tool list (see `presets.ts`), as Claude Code's
4
+ * sub-agents reference defines it:
5
+ *
6
+ * - `model` / `effort`: the agent's requests run on that route when DSH
7
+ * serves the model; otherwise the parent's model is kept and the session
8
+ * records why.
9
+ * - `skills`: the full content of each listed model-invocable skill (first 32
10
+ * distinct names) enters the agent's context when it starts.
11
+ * - `mcpServers`: inline definitions connect when the agent starts, for that
12
+ * agent only, and disconnect when it ends; names reuse configured servers.
13
+ * - `maxTurns`: the agent stops after that many model calls and its answer
14
+ * so far is returned, marked partial.
15
+ * - `memory`: `user` (`~/.claude/agent-memory/<name>/`), `project`
16
+ * (`.claude/agent-memory/<name>/`) or `local`
17
+ * (`.claude/agent-memory-local/<name>/`); the agent starts with the memory
18
+ * instructions and the first 200 lines or 25 KB of `MEMORY.md`.
19
+ * - `isolation: worktree`: the agent runs in a fresh git worktree of the
20
+ * repository, removed afterwards when the agent changed nothing.
21
+ * - `initialPrompt`: submitted as the first message when the agent's preset
22
+ * is the session's own (the Web preset picker, Claude's `--agent`).
23
+ * @module @kirkchinese/harness-forge
24
+ */
25
+ import { randomUUID } from 'node:crypto';
26
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
27
+ import { homedir } from 'node:os';
28
+ import { join } from 'node:path';
29
+ import { createUserMessage } from '@deepseek-ai/dsh-llm';
30
+ import { renderSkillContent } from '@deepseek-ai/dsh-skill';
31
+ import { kebabCase, toolList } from '@kirkchinese/harness-forge-core';
32
+ import { appendNotice } from '../hooks/notice.js';
33
+ import { resolveRoute } from '../shared/invocation.js';
34
+ import { selectRoute } from '../dsh/model-route.js';
35
+ import { mcpServerName, mountMcp } from '../mcp/mount.js';
36
+ import { dshService, onDsh, presetOfSession } from '../dsh/host.js';
37
+ /** Read the run-time fields of an agent's frontmatter. */
38
+ export function agentRuntimeFields(frontmatter) {
39
+ const string = (key) => typeof frontmatter[key] === 'string' && frontmatter[key].trim().length > 0 ? frontmatter[key].trim() : undefined;
40
+ const model = string('model');
41
+ const effort = string('effort');
42
+ const memory = string('memory');
43
+ const maxTurns = typeof frontmatter['maxTurns'] === 'number' ? frontmatter['maxTurns'] : Number(string('maxTurns') ?? Number.NaN);
44
+ const initialPrompt = string('initialPrompt');
45
+ const servers = [];
46
+ const raw = frontmatter['mcpServers'];
47
+ const entries = Array.isArray(raw) ? raw : raw !== null && typeof raw === 'object' ? [raw] : typeof raw === 'string' ? toolList(raw) ?? [] : [];
48
+ for (const entry of entries) {
49
+ if (typeof entry === 'string')
50
+ servers.push({ name: entry });
51
+ else if (entry !== null && typeof entry === 'object') {
52
+ for (const [name, config] of Object.entries(entry)) {
53
+ if (config !== null && typeof config === 'object')
54
+ servers.push({ name, config: config });
55
+ }
56
+ }
57
+ }
58
+ return {
59
+ ...(model !== undefined && model !== 'inherit' ? { model } : {}),
60
+ ...(effort !== undefined ? { effort: effort.toLowerCase() } : {}),
61
+ skills: [...new Set(toolList(frontmatter['skills']) ?? [])].slice(0, 32),
62
+ mcpServers: servers,
63
+ ...(Number.isInteger(maxTurns) && maxTurns > 0 ? { maxTurns } : {}),
64
+ ...(memory === 'user' || memory === 'project' || memory === 'local' ? { memory } : {}),
65
+ ...(string('isolation') === 'worktree' ? { isolation: 'worktree' } : {}),
66
+ ...(initialPrompt !== undefined ? { initialPrompt } : {}),
67
+ };
68
+ }
69
+ /** The memory directory of an agent for a scope. */
70
+ export function agentMemoryDir(scope, name, projectDir, home = homedir()) {
71
+ if (scope === 'user')
72
+ return join(home, '.claude', 'agent-memory', name);
73
+ return join(projectDir, '.claude', scope === 'project' ? 'agent-memory' : 'agent-memory-local', name);
74
+ }
75
+ const MEMORY_LINES = 200;
76
+ const MEMORY_BYTES = 25 * 1024;
77
+ /** The memory instructions an agent starts with. */
78
+ export function memoryInstructions(dir) {
79
+ const path = join(dir, 'MEMORY.md');
80
+ let excerpt = '';
81
+ let cut = false;
82
+ if (existsSync(path)) {
83
+ const text = readFileSync(path, 'utf8');
84
+ const lines = text.split(/\r?\n/u);
85
+ excerpt = lines.slice(0, MEMORY_LINES).join('\n');
86
+ if (Buffer.byteLength(excerpt) > MEMORY_BYTES)
87
+ excerpt = Buffer.from(excerpt).subarray(0, MEMORY_BYTES).toString('utf8');
88
+ cut = lines.length > MEMORY_LINES || excerpt.length < text.length;
89
+ }
90
+ return [
91
+ '# Agent memory',
92
+ '',
93
+ `You have a persistent memory directory at ${dir}. It survives across conversations: read it before you start, and save what you learn there (codebase patterns, debugging insights, decisions and where things live) with the Read, Write and Edit tools.`,
94
+ '`MEMORY.md` is the index: keep it short, one line per topic, with details in other files of the directory.',
95
+ '',
96
+ excerpt.length > 0 ? `Current MEMORY.md:\n\n${excerpt}` : 'MEMORY.md does not exist yet.',
97
+ ...(cut ? ['', `MEMORY.md is longer than ${String(MEMORY_LINES)} lines or 25 KB; curate it so the index fits.`] : []),
98
+ ].join('\n');
99
+ }
100
+ /** Run-time effects of imported agents' frontmatter. */
101
+ export class AgentProfiles {
102
+ ctx;
103
+ shell;
104
+ dataRoot;
105
+ remoteHost;
106
+ profiles = new Map();
107
+ runs = new Map();
108
+ /** Worktrees created for isolated agents, by path. */
109
+ worktrees = new Map();
110
+ constructor(ctx, shell, dataRoot, remoteHost) {
111
+ this.ctx = ctx;
112
+ this.shell = shell;
113
+ this.dataRoot = dataRoot;
114
+ this.remoteHost = remoteHost;
115
+ }
116
+ register(profile) {
117
+ this.profiles.set(profile.presetId, profile);
118
+ return () => { if (this.profiles.get(profile.presetId) === profile)
119
+ this.profiles.delete(profile.presetId); };
120
+ }
121
+ /** The preset of an `agent` tool call that runs an isolated agent, for its worktree. */
122
+ isolated(presetId) {
123
+ return typeof presetId === 'string' && this.profiles.has(presetId) && agentRuntimeFields(this.profiles.get(presetId).frontmatter).isolation === 'worktree';
124
+ }
125
+ /** Listen on the host. Returns the disposer. */
126
+ install() {
127
+ const on = (name, listener, options) => onDsh(this.ctx, name, listener, { ...options, owner: 'agents' });
128
+ const disposers = [
129
+ on('agent/created', ((payload) => this.created(payload.agent, payload.signal ?? new AbortController().signal))),
130
+ on('agent/pre-step', (async (payload, next) => {
131
+ const run = this.runs.get(payload.agent.session.header.id);
132
+ const profile = run === undefined ? undefined : this.profiles.get(run.presetId);
133
+ const maxTurns = profile === undefined ? undefined : agentRuntimeFields(profile.frontmatter).maxTurns;
134
+ if (run === undefined || maxTurns === undefined)
135
+ return next();
136
+ run.steps++;
137
+ if (run.steps > maxTurns) {
138
+ appendNotice(payload.agent.session, { kind: 'stopped', event: 'SubagentStop', subject: profile.name, plugin: profile.pluginId, text: `${profile.name} reached maxTurns (${String(maxTurns)}); its output so far is partial` });
139
+ return { kind: 'reject' };
140
+ }
141
+ return next();
142
+ })),
143
+ on('agent/disposed', ((payload) => { void this.disposed(payload.agent); })),
144
+ ];
145
+ return () => { for (const dispose of disposers)
146
+ dispose(); };
147
+ }
148
+ presetOf(agent) {
149
+ const value = presetOfSession(this.ctx, agent.session);
150
+ if (value !== undefined)
151
+ return value;
152
+ // Fall back to the composed preset.
153
+ const presets = dshService(this.ctx, 'agentPresets');
154
+ try {
155
+ return presets?.composedPreset?.(agent.ctx);
156
+ }
157
+ catch {
158
+ return undefined;
159
+ }
160
+ }
161
+ async created(agent, signal) {
162
+ const presetId = this.presetOf(agent);
163
+ const profile = presetId === undefined ? undefined : this.profiles.get(presetId);
164
+ if (profile === undefined || presetId === undefined)
165
+ return;
166
+ const fields = agentRuntimeFields(profile.frontmatter);
167
+ const depth = agent.session.header.delegationDepth ?? 0;
168
+ if (depth === 0) {
169
+ // The session's own agent: Claude's `--agent`.
170
+ if (fields.initialPrompt !== undefined)
171
+ agent.followup(createUserMessage({ content: [{ type: 'text', text: fields.initialPrompt }], source: { kind: 'user' } }));
172
+ return;
173
+ }
174
+ const run = { presetId, steps: 0, disposers: [] };
175
+ this.runs.set(agent.session.header.id, run);
176
+ const cwd = agent.session.header.cwd ?? process.cwd();
177
+ if (fields.model !== undefined || fields.effort !== undefined) {
178
+ const resolved = await resolveRoute(this.ctx, agent.options ?? {}, fields.model, fields.effort, signal);
179
+ if (resolved.route !== undefined) {
180
+ run.route = resolved.route;
181
+ selectRoute(agent, resolved.route);
182
+ }
183
+ if (resolved.note !== undefined)
184
+ appendNotice(agent.session, { kind: 'feedback', event: 'SubagentStart', subject: profile.name, plugin: profile.pluginId, text: resolved.note });
185
+ }
186
+ for (const server of fields.mcpServers) {
187
+ if (server.config === undefined)
188
+ continue;
189
+ try {
190
+ const component = inlineServer(profile, server.name, server.config);
191
+ const mount = await mountMcp(agent.ctx, component, mcpServerName(server.name), profile.vars, this.remoteHost(component.id), { catalog: false });
192
+ run.disposers.push(mount.dispose);
193
+ }
194
+ catch (error) {
195
+ appendNotice(agent.session, { kind: 'hook-error', event: 'SubagentStart', subject: profile.name, plugin: profile.pluginId, text: `MCP server ${server.name} of ${profile.name} did not start: ${error instanceof Error ? error.message : String(error)}` });
196
+ }
197
+ }
198
+ const skills = dshService(this.ctx, 'skills');
199
+ for (const name of fields.skills) {
200
+ const skill = await skills?.get(kebabCase(name), { cwd, scope: agent, signal }).catch(() => undefined);
201
+ if (skill === undefined || skill.invocation?.modelInvocable === false) {
202
+ appendNotice(agent.session, { kind: 'feedback', event: 'SubagentStart', subject: profile.name, plugin: profile.pluginId, text: `skill ${name} listed by ${profile.name} is missing or user-only; not preloaded` });
203
+ continue;
204
+ }
205
+ agent.inject(createUserMessage({ content: [{ type: 'text', text: renderSkillContent(skill) }], source: { kind: 'skill-invocation', name: skill.name, form: 'instructions' } }));
206
+ }
207
+ if (fields.memory !== undefined) {
208
+ const dir = agentMemoryDir(fields.memory, profile.name, cwd);
209
+ mkdirSync(dir, { recursive: true });
210
+ agent.inject(createUserMessage({ content: [{ type: 'text', text: memoryInstructions(dir) }], source: { kind: 'user' } }));
211
+ }
212
+ }
213
+ async disposed(agent) {
214
+ const run = this.runs.get(agent.session.header.id);
215
+ this.runs.delete(agent.session.header.id);
216
+ for (const dispose of run?.disposers ?? [])
217
+ await dispose().catch(() => undefined);
218
+ const cwd = agent.session.header.cwd;
219
+ const worktree = cwd === undefined ? undefined : this.worktrees.get(cwd);
220
+ if (cwd === undefined || worktree === undefined)
221
+ return;
222
+ // Claude Code removes an isolated agent's worktree when the agent changed nothing.
223
+ const status = await this.shell.runExec('git', ['status', '--porcelain'], { cwd });
224
+ if (status.exitCode === 0 && status.stdout.trim().length === 0) {
225
+ const ahead = await this.shell.runExec('git', ['log', '--oneline', `${worktree.base}..HEAD`], { cwd });
226
+ if (ahead.exitCode === 0 && ahead.stdout.trim().length === 0) {
227
+ await this.shell.runExec('git', ['worktree', 'remove', '--force', cwd], { cwd: worktree.repo });
228
+ await this.shell.runExec('git', ['branch', '-D', worktree.branch], { cwd: worktree.repo });
229
+ this.worktrees.delete(cwd);
230
+ }
231
+ }
232
+ }
233
+ /**
234
+ * Create the worktree an isolated agent runs in, branched from the
235
+ * repository's current HEAD.
236
+ * @returns the worktree directory, or undefined outside a git repository.
237
+ */
238
+ async worktree(cwd) {
239
+ const top = await this.shell.runExec('git', ['rev-parse', '--show-toplevel'], { cwd });
240
+ if (top.exitCode !== 0)
241
+ return undefined;
242
+ const repo = top.stdout.trim();
243
+ const base = (await this.shell.runExec('git', ['rev-parse', 'HEAD'], { cwd: repo })).stdout.trim();
244
+ const id = randomUUID().slice(0, 8);
245
+ const path = join(this.dataRoot, 'worktrees', id);
246
+ const branch = `harness-forge/agent-${id}`;
247
+ mkdirSync(join(this.dataRoot, 'worktrees'), { recursive: true });
248
+ const added = await this.shell.runExec('git', ['worktree', 'add', '-b', branch, path, base], { cwd: repo });
249
+ if (added.exitCode !== 0)
250
+ throw new Error(`git worktree add failed: ${added.stderr.trim()}`);
251
+ this.worktrees.set(path, { repo, branch, base });
252
+ return path;
253
+ }
254
+ }
255
+ function inlineServer(profile, name, config) {
256
+ const type = typeof config['type'] === 'string' ? config['type'] : undefined;
257
+ const transport = type === 'sse' ? 'sse'
258
+ : type === 'http' || type === 'streamable-http' ? 'streamable-http'
259
+ : typeof config['command'] === 'string' ? 'stdio'
260
+ : typeof config['url'] === 'string' ? 'streamable-http' : 'unknown';
261
+ const strings = (value) => value !== null && typeof value === 'object'
262
+ ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === 'string'))
263
+ : undefined;
264
+ const env = strings(config['env']);
265
+ const headers = strings(config['headers']);
266
+ return {
267
+ id: `${profile.pluginId}:mcp:${profile.name}-${name}`,
268
+ kind: 'mcp',
269
+ name,
270
+ transport,
271
+ ...(typeof config['command'] === 'string' ? { command: config['command'] } : {}),
272
+ ...(Array.isArray(config['args']) ? { args: config['args'].map(String) } : {}),
273
+ ...(env !== undefined ? { env } : {}),
274
+ ...(typeof config['cwd'] === 'string' ? { cwd: config['cwd'] } : {}),
275
+ ...(typeof config['url'] === 'string' ? { url: config['url'] } : {}),
276
+ ...(headers !== undefined ? { headers } : {}),
277
+ };
278
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The agents row: imported agents become DSH agent presets offered through
3
+ * one delegation tool (a session's project agents through a tool of its own),
4
+ * with their frontmatter's run-time effects (`model`, `skills`, `mcpServers`,
5
+ * `maxTurns`, `memory`, `isolation: worktree`, `initialPrompt`), and the hooks
6
+ * their frontmatter declares, which the hooks row runs.
7
+ * @module @kirkchinese/harness-forge/agents
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ import type { Disposer } from '../forge/contract.js';
11
+ import { type HarnessForge } from '../forge/service.js';
12
+ export declare const name = "harness-forge-agents";
13
+ export declare const inject: string[];
14
+ /** The agents row. */
15
+ export declare function apply(ctx: Context): void;
16
+ /** Start the agents row on the shared service. Returns its teardown. */
17
+ export declare function startAgents(ctx: Context, forge: HarnessForge): Disposer;
@@ -0,0 +1,146 @@
1
+ import { HarnessError } from '@kirkchinese/harness-forge-core';
2
+ import { AgentProfiles } from './profiles.js';
3
+ import { AgentTool, mountAgentPreset } from './presets.js';
4
+ import { dshService, onDsh, presetOfSession } from '../dsh/host.js';
5
+ import { FORGE_SERVICE } from '../forge/service.js';
6
+ import { hookSource, parseHookTable } from '../hooks/config.js';
7
+ import { isOwnAssets } from '../mcp/mount.js';
8
+ import { messageOf } from '../shared/util.js';
9
+ import { mounted, Parts, rowEffect } from '../forge/row.js';
10
+ export const name = 'harness-forge-agents';
11
+ export const inject = [FORGE_SERVICE];
12
+ /** The agents row. */
13
+ export function apply(ctx) {
14
+ rowEffect(ctx, 'agents', forge => startAgents(ctx, forge));
15
+ }
16
+ /** Start the agents row on the shared service. Returns its teardown. */
17
+ export function startAgents(ctx, forge) {
18
+ const agents = new AgentTool(ctx);
19
+ /** Each session's own delegation tool, for its project agents. */
20
+ const sessionAgents = new Map();
21
+ /** The component of each mounted preset, for its run evidence. */
22
+ const presets = new Map();
23
+ const agentHooks = new Map();
24
+ const remoteHost = (componentId) => {
25
+ const mcp = forge.lookup('mcp');
26
+ if (mcp === undefined)
27
+ throw new Error('the agent\'s MCP servers need the Harness Forge mcp row, which is off');
28
+ return mcp.remoteHost(componentId);
29
+ };
30
+ const profiles = new AgentProfiles(ctx, forge.shell, forge.dataRoot, remoteHost);
31
+ const toolOf = (scope) => {
32
+ if (scope.ctx === undefined || scope.sessionId === undefined)
33
+ return agents;
34
+ let tool = sessionAgents.get(scope.sessionId);
35
+ if (tool === undefined) {
36
+ tool = new AgentTool(scope.ctx, agents);
37
+ // A tool mounted in an agent's context takes no config updates: it starts once, with every project agent.
38
+ tool.hold();
39
+ sessionAgents.set(scope.sessionId, tool);
40
+ }
41
+ return tool;
42
+ };
43
+ /** An agent with `isolation: worktree` starts in a fresh git worktree of the repository. */
44
+ const isolate = async (exec, next) => {
45
+ const args = exec.arguments;
46
+ if (exec.agent === undefined || !profiles.isolated(args?.agent_preset))
47
+ return next();
48
+ const base = typeof args?.cwd === 'string' && args.cwd.length > 0 ? args.cwd : await forge.directory(exec.agent, exec.signal);
49
+ const worktree = await profiles.worktree(base);
50
+ if (worktree === undefined)
51
+ return next();
52
+ const tools = dshService(ctx, 'tools');
53
+ const definition = tools?.get(exec.name, exec.agent);
54
+ if (definition === undefined)
55
+ return next();
56
+ const isolated = { ...exec.arguments, cwd: worktree };
57
+ try {
58
+ const value = await definition.execute(isolated, exec);
59
+ return { isError: false, value, content: definition.output.render(isolated, value) };
60
+ }
61
+ catch (error) {
62
+ const message = messageOf(error);
63
+ return { isError: true, error: { message }, content: [{ type: 'text', text: `Error: ${message}` }] };
64
+ }
65
+ };
66
+ /** A delegated run under an imported preset is evidence for its component. */
67
+ const observeRun = (childId, ok, detail) => {
68
+ const child = dshService(ctx, 'agents')?.get(childId);
69
+ if (child === undefined)
70
+ return;
71
+ const preset = presetOfSession(ctx, child.session);
72
+ const componentId = preset === undefined ? undefined : presets.get(preset);
73
+ if (componentId !== undefined)
74
+ forge.observe(componentId, 'agent-run', ok, detail);
75
+ };
76
+ const api = {
77
+ foreignName: presetId => agents.foreignName(presetId),
78
+ presetOf: foreignName => agents.presetOf(foreignName),
79
+ agentHooks: presetId => agentHooks.get(presetId),
80
+ };
81
+ const parts = new Parts(ctx, forge, 'agents');
82
+ parts.add('profiles', () => profiles.install());
83
+ parts.add('isolation', () => onDsh(ctx, 'tools/execute', ((exec, next) => isolate(exec, next)), { owner: 'agents' }));
84
+ parts.add('run evidence', () => {
85
+ const stops = [
86
+ onDsh(ctx, 'subagent/start', ((info) => { observeRun(info.id, true, 'delegated run started'); }), { owner: 'agents' }),
87
+ onDsh(ctx, 'subagent/end', ((info) => { observeRun(info.id, info.stopReason !== 'error', `delegated run ended: ${info.stopReason}`); }), { owner: 'agents' }),
88
+ ];
89
+ return () => { for (const stop of stops)
90
+ stop(); };
91
+ });
92
+ parts.add('delegation tool', () => () => agents.dispose());
93
+ parts.add('agent mounter', () => forge.registerMounter('agent', {
94
+ mount: async ({ component, plugin, dataDir, scope }) => {
95
+ if (component.kind !== 'agent')
96
+ throw new HarnessError('component-failed', `action expects an agent: ${component.id}`);
97
+ const mount = await mountAgentPreset(scope.ctx ?? ctx, component, plugin.name);
98
+ const withdraw = toolOf(scope).add(mount.presetId, isOwnAssets(plugin) ? component.name : `${plugin.name}:${component.name}`);
99
+ presets.set(mount.presetId, component.id);
100
+ const hooks = component.frontmatter['hooks'];
101
+ const source = hooks === undefined ? undefined : hookSource(component.id, plugin, dataDir, parseHookTable(hooks), 'agent');
102
+ if (source !== undefined)
103
+ agentHooks.set(mount.presetId, source);
104
+ // `model`, `effort`, `skills`, `mcpServers`, `maxTurns`, `memory`, `isolation`, `initialPrompt`.
105
+ const withdrawProfile = profiles.register({
106
+ presetId: mount.presetId,
107
+ name: component.name,
108
+ pluginId: plugin.id,
109
+ frontmatter: component.frontmatter,
110
+ vars: { pluginRoot: plugin.root, dataDir, env: forge.settings.env() },
111
+ });
112
+ return {
113
+ outcome: mounted(component, 'L1b', mount.presetId),
114
+ disposer: async () => {
115
+ if (presets.get(mount.presetId) === component.id)
116
+ presets.delete(mount.presetId);
117
+ if (source !== undefined && agentHooks.get(mount.presetId) === source)
118
+ agentHooks.delete(mount.presetId);
119
+ withdraw();
120
+ withdrawProfile();
121
+ await mount.dispose();
122
+ },
123
+ };
124
+ },
125
+ // The delegation tool restarts on each agent change; the next request must see them all.
126
+ settle: async (scope) => {
127
+ const tool = toolOf(scope);
128
+ tool.resume();
129
+ await tool.settled();
130
+ },
131
+ release: async (scope) => {
132
+ if (scope.sessionId === undefined)
133
+ return;
134
+ const tool = sessionAgents.get(scope.sessionId);
135
+ sessionAgents.delete(scope.sessionId);
136
+ await tool?.dispose();
137
+ },
138
+ }));
139
+ // A preset registry that starts after this row retries the agents that needed it.
140
+ parts.add('preset registry', () => {
141
+ const fiber = ctx.inject(['agentPresets'], () => { forge.ledger.reapply(); });
142
+ return () => fiber.dispose();
143
+ });
144
+ parts.add('api', () => forge.provide('agents', api));
145
+ return () => parts.dispose();
146
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The page's stylesheet, rendered once by the page so unmounting removes it.
3
+ * Classes carry the `hf-` prefix; colors and radii are DSH theme tokens, and
4
+ * the layout follows Plugin Manager (960px column, 20px title, list rows that
5
+ * reach 8px past the text on hover).
6
+ * @module @kirkchinese/harness-forge/client
7
+ */
8
+ export declare const CSS = "\n.hf-page { height: 100%; overflow-y: auto; box-sizing: border-box; padding: 0 clamp(24px, 4vw, 48px) 48px; color: var(--dsw-alias-label-primary); }\n.hf-column { max-width: 960px; margin: 0 auto; }\n.hf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-top: 28px; flex-wrap: wrap; }\n[data-platform='darwin'] .hf-head { padding-top: calc(28px + var(--dsh-frame-top-clearance, 0px)); }\n.hf-title { margin: 0; font-size: 20px; font-weight: 500; line-height: 28px; }\n.hf-subtitle { margin: 4px 0 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n.hf-actions { display: flex; align-items: center; gap: 8px; position: relative; }\n.hf-tabs { display: inline-flex; gap: 2px; padding: 2px; margin: 20px 0 24px; border-radius: var(--dsw-radius-md, 8px); background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-interactive-bg-hover)); }\n.hf-tab { height: 30px; padding: 0 14px; border: 0; border-radius: calc(var(--dsw-radius-md, 8px) - 2px); background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }\n.hf-tab[aria-selected='true'] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font-weight: 500; box-shadow: 0 0 0 0.5px var(--dsw-alias-border-l2); }\n.hf-count { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); }\n.hf-btn { height: 28px; padding: 0 12px; border-radius: var(--dsw-radius-md, 8px); border: 0.5px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }\n.hf-btn:disabled { opacity: 0.5; cursor: default; }\n.hf-btn-primary { border-color: var(--dsw-alias-button-primary-fill); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }\n.hf-btn-danger { color: var(--dsw-alias-state-error-primary); }\n.hf-btn-link { border: 0; background: transparent; padding: 0 4px; color: var(--dsw-alias-label-secondary); }\n@media (hover: hover) {\n .hf-btn:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n .hf-btn-primary:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover, var(--dsw-alias-button-primary-fill)); }\n .hf-btn-danger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover-danger, var(--dsw-alias-interactive-bg-hover)); }\n .hf-btn-link:hover:not(:disabled) { color: var(--dsw-alias-label-primary); background: transparent; }\n .hf-tab:hover:not([aria-selected='true']) { color: var(--dsw-alias-label-primary); }\n .hf-row-button:hover { background: var(--dsw-alias-interactive-bg-hover); }\n .hf-menu-item:hover { background: var(--dsw-alias-interactive-bg-hover); }\n}\n.hf-btn:focus-visible, .hf-tab:focus-visible, .hf-switch:focus-visible, .hf-row-button:focus-visible, .hf-menu-item:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 1px; }\n.hf-menu { position: absolute; top: 34px; right: 0; z-index: 5; min-width: 180px; padding: 4px; border-radius: var(--dsw-radius-lg, 10px); background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base)); border: 0.5px solid var(--dsw-alias-border-l2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }\n.hf-menu-item { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--dsw-radius-sm, 6px); background: transparent; color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }\n.hf-intro { display: flex; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 12px 14px; border-radius: var(--dsw-radius-lg, 10px); background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n.hf-intro p { margin: 0; flex: 1; }\n.hf-section { margin-bottom: 32px; }\n.hf-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }\n.hf-section-title { margin: 0; font-size: 14px; line-height: 22px; font-weight: 500; display: flex; align-items: center; gap: 8px; }\n.hf-lead { margin: 0 0 16px; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n.hf-muted { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n.hf-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; padding: 0; list-style: none; }\n.hf-item { border-radius: var(--dsw-radius-xl, 12px); }\n.hf-item[data-open='true'] { background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-interactive-bg-hover)); }\n.hf-item-head { display: flex; align-items: center; gap: 12px; padding: 10px 8px; }\n.hf-row-button { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px; margin: -4px; border: 0; border-radius: var(--dsw-radius-md, 8px); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }\n.hf-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n.hf-item-title { font-size: 14px; line-height: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }\n.hf-item-desc { font-size: 13px; line-height: 18px; color: var(--dsw-alias-label-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hf-tag { flex: none; padding: 0 6px; border-radius: 4px; font-size: 11px; line-height: 18px; font-weight: 400; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); }\n.hf-verdict { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; width: 132px; }\n.hf-verdict-label { font-size: 12px; line-height: 16px; display: flex; align-items: center; gap: 6px; }\n.hf-bar { display: flex; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; background: var(--dsw-alias-interactive-bg-hover); }\n.hf-bar > span { display: block; height: 100%; }\n.hf-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; }\n.hf-parts { padding: 0 8px 10px 34px; display: flex; flex-direction: column; gap: 2px; }\n.hf-part { display: flex; align-items: flex-start; gap: 12px; padding: 7px 0; border-top: 0.5px solid var(--dsw-alias-border-l3); }\n.hf-part:first-child { border-top: 0; }\n.hf-part-main { flex: 1; min-width: 0; font-size: 13px; line-height: 20px; }\n.hf-part-name { font-weight: 500; overflow-wrap: anywhere; }\n.hf-part-kind { color: var(--dsw-alias-label-tertiary); margin-right: 8px; font-size: 12px; }\n.hf-part-state { flex: none; width: 130px; font-size: 12px; line-height: 20px; display: flex; align-items: center; gap: 6px; color: var(--dsw-alias-label-secondary); }\n.hf-reason { font-size: 12.5px; line-height: 18px; color: var(--dsw-alias-label-secondary); margin-top: 2px; }\n.hf-code { font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 12px; overflow-wrap: anywhere; color: var(--dsw-alias-label-tertiary); }\n.hf-switch { flex: none; position: relative; width: 32px; height: 18px; margin-top: 1px; border: 0; border-radius: 9px; padding: 0; background: var(--dsw-alias-border-l2); cursor: pointer; transition: background 120ms; }\n.hf-switch[aria-checked='true'] { background: var(--dsw-alias-state-business-primary); }\n.hf-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 120ms; }\n.hf-switch[aria-checked='true']::after { transform: translateX(14px); }\n.hf-switch:disabled { opacity: 0.5; cursor: default; }\n.hf-input, .hf-select, .hf-textarea { box-sizing: border-box; height: 32px; padding: 0 10px; border-radius: var(--dsw-radius-md, 8px); border: 0.5px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); color: inherit; font: inherit; font-size: 13px; }\n.hf-input { flex: 1 1 280px; min-width: 200px; }\n.hf-textarea { width: 100%; height: auto; min-height: 132px; padding: 8px 10px; resize: vertical; line-height: 20px; }\n@media (pointer: coarse) { .hf-input, .hf-select, .hf-textarea { font-size: 16px; } }\n.hf-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }\n.hf-card { font-size: 13px; line-height: 20px; padding: 14px 16px; border-radius: var(--dsw-radius-xl, 12px); background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); border: 0.5px solid var(--dsw-alias-settings-card-stroke, transparent); }\n.hf-notice { margin: 16px 0 0; padding: 9px 12px; border-radius: var(--dsw-radius-md, 8px); font-size: 13px; line-height: 20px; white-space: pre-wrap; background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); }\n.hf-notice[data-kind='error'] { color: var(--dsw-alias-state-error-primary); }\n.hf-notice-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.hf-empty { padding: 20px 0; font-size: 13px; color: var(--dsw-alias-label-tertiary); }\n.hf-facts { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; margin: 0; }\n.hf-facts dt, .hf-facts dd { margin: 0; padding: 9px 0; border-top: 0.5px solid var(--dsw-alias-border-l3); font-size: 13px; line-height: 20px; }\n.hf-facts dt { color: var(--dsw-alias-label-secondary); }\n.hf-facts dd { overflow-wrap: anywhere; }\n.hf-brief { max-height: 320px; overflow: auto; margin: 10px 0; padding: 10px 12px; border-radius: var(--dsw-radius-md, 8px); background: var(--dsw-alias-bg-base); font-family: var(--dsw-font-mono, ui-monospace, monospace); font-size: 12px; line-height: 18px; white-space: pre-wrap; }\n.hf-details summary { cursor: pointer; font-size: 13px; color: var(--dsw-alias-label-secondary); }\n.hf-back { margin: 20px 0 4px -4px; }\n";
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The page's stylesheet, rendered once by the page so unmounting removes it.
3
+ * Classes carry the `hf-` prefix; colors and radii are DSH theme tokens, and
4
+ * the layout follows Plugin Manager (960px column, 20px title, list rows that
5
+ * reach 8px past the text on hover).
6
+ * @module @kirkchinese/harness-forge/client
7
+ */
8
+ export const CSS = `
9
+ .hf-page { height: 100%; overflow-y: auto; box-sizing: border-box; padding: 0 clamp(24px, 4vw, 48px) 48px; color: var(--dsw-alias-label-primary); }
10
+ .hf-column { max-width: 960px; margin: 0 auto; }
11
+ .hf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-top: 28px; flex-wrap: wrap; }
12
+ [data-platform='darwin'] .hf-head { padding-top: calc(28px + var(--dsh-frame-top-clearance, 0px)); }
13
+ .hf-title { margin: 0; font-size: 20px; font-weight: 500; line-height: 28px; }
14
+ .hf-subtitle { margin: 4px 0 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
15
+ .hf-actions { display: flex; align-items: center; gap: 8px; position: relative; }
16
+ .hf-tabs { display: inline-flex; gap: 2px; padding: 2px; margin: 20px 0 24px; border-radius: var(--dsw-radius-md, 8px); background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-interactive-bg-hover)); }
17
+ .hf-tab { height: 30px; padding: 0 14px; border: 0; border-radius: calc(var(--dsw-radius-md, 8px) - 2px); background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
18
+ .hf-tab[aria-selected='true'] { background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font-weight: 500; box-shadow: 0 0 0 0.5px var(--dsw-alias-border-l2); }
19
+ .hf-count { min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); }
20
+ .hf-btn { height: 28px; padding: 0 12px; border-radius: var(--dsw-radius-md, 8px); border: 0.5px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
21
+ .hf-btn:disabled { opacity: 0.5; cursor: default; }
22
+ .hf-btn-primary { border-color: var(--dsw-alias-button-primary-fill); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
23
+ .hf-btn-danger { color: var(--dsw-alias-state-error-primary); }
24
+ .hf-btn-link { border: 0; background: transparent; padding: 0 4px; color: var(--dsw-alias-label-secondary); }
25
+ @media (hover: hover) {
26
+ .hf-btn:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
27
+ .hf-btn-primary:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover, var(--dsw-alias-button-primary-fill)); }
28
+ .hf-btn-danger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover-danger, var(--dsw-alias-interactive-bg-hover)); }
29
+ .hf-btn-link:hover:not(:disabled) { color: var(--dsw-alias-label-primary); background: transparent; }
30
+ .hf-tab:hover:not([aria-selected='true']) { color: var(--dsw-alias-label-primary); }
31
+ .hf-row-button:hover { background: var(--dsw-alias-interactive-bg-hover); }
32
+ .hf-menu-item:hover { background: var(--dsw-alias-interactive-bg-hover); }
33
+ }
34
+ .hf-btn:focus-visible, .hf-tab:focus-visible, .hf-switch:focus-visible, .hf-row-button:focus-visible, .hf-menu-item:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 1px; }
35
+ .hf-menu { position: absolute; top: 34px; right: 0; z-index: 5; min-width: 180px; padding: 4px; border-radius: var(--dsw-radius-lg, 10px); background: var(--dsw-alias-bg-layer-1, var(--dsw-alias-bg-base)); border: 0.5px solid var(--dsw-alias-border-l2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
36
+ .hf-menu-item { display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--dsw-radius-sm, 6px); background: transparent; color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
37
+ .hf-intro { display: flex; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 12px 14px; border-radius: var(--dsw-radius-lg, 10px); background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
38
+ .hf-intro p { margin: 0; flex: 1; }
39
+ .hf-section { margin-bottom: 32px; }
40
+ .hf-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
41
+ .hf-section-title { margin: 0; font-size: 14px; line-height: 22px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
42
+ .hf-lead { margin: 0 0 16px; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
43
+ .hf-muted { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
44
+ .hf-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; padding: 0; list-style: none; }
45
+ .hf-item { border-radius: var(--dsw-radius-xl, 12px); }
46
+ .hf-item[data-open='true'] { background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-interactive-bg-hover)); }
47
+ .hf-item-head { display: flex; align-items: center; gap: 12px; padding: 10px 8px; }
48
+ .hf-row-button { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px; margin: -4px; border: 0; border-radius: var(--dsw-radius-md, 8px); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
49
+ .hf-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
50
+ .hf-item-title { font-size: 14px; line-height: 20px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
51
+ .hf-item-desc { font-size: 13px; line-height: 18px; color: var(--dsw-alias-label-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
52
+ .hf-tag { flex: none; padding: 0 6px; border-radius: 4px; font-size: 11px; line-height: 18px; font-weight: 400; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); }
53
+ .hf-verdict { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; width: 132px; }
54
+ .hf-verdict-label { font-size: 12px; line-height: 16px; display: flex; align-items: center; gap: 6px; }
55
+ .hf-bar { display: flex; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; background: var(--dsw-alias-interactive-bg-hover); }
56
+ .hf-bar > span { display: block; height: 100%; }
57
+ .hf-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; display: inline-block; }
58
+ .hf-parts { padding: 0 8px 10px 34px; display: flex; flex-direction: column; gap: 2px; }
59
+ .hf-part { display: flex; align-items: flex-start; gap: 12px; padding: 7px 0; border-top: 0.5px solid var(--dsw-alias-border-l3); }
60
+ .hf-part:first-child { border-top: 0; }
61
+ .hf-part-main { flex: 1; min-width: 0; font-size: 13px; line-height: 20px; }
62
+ .hf-part-name { font-weight: 500; overflow-wrap: anywhere; }
63
+ .hf-part-kind { color: var(--dsw-alias-label-tertiary); margin-right: 8px; font-size: 12px; }
64
+ .hf-part-state { flex: none; width: 130px; font-size: 12px; line-height: 20px; display: flex; align-items: center; gap: 6px; color: var(--dsw-alias-label-secondary); }
65
+ .hf-reason { font-size: 12.5px; line-height: 18px; color: var(--dsw-alias-label-secondary); margin-top: 2px; }
66
+ .hf-code { font-family: var(--dsw-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 12px; overflow-wrap: anywhere; color: var(--dsw-alias-label-tertiary); }
67
+ .hf-switch { flex: none; position: relative; width: 32px; height: 18px; margin-top: 1px; border: 0; border-radius: 9px; padding: 0; background: var(--dsw-alias-border-l2); cursor: pointer; transition: background 120ms; }
68
+ .hf-switch[aria-checked='true'] { background: var(--dsw-alias-state-business-primary); }
69
+ .hf-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 120ms; }
70
+ .hf-switch[aria-checked='true']::after { transform: translateX(14px); }
71
+ .hf-switch:disabled { opacity: 0.5; cursor: default; }
72
+ .hf-input, .hf-select, .hf-textarea { box-sizing: border-box; height: 32px; padding: 0 10px; border-radius: var(--dsw-radius-md, 8px); border: 0.5px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-base); color: inherit; font: inherit; font-size: 13px; }
73
+ .hf-input { flex: 1 1 280px; min-width: 200px; }
74
+ .hf-textarea { width: 100%; height: auto; min-height: 132px; padding: 8px 10px; resize: vertical; line-height: 20px; }
75
+ @media (pointer: coarse) { .hf-input, .hf-select, .hf-textarea { font-size: 16px; } }
76
+ .hf-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
77
+ .hf-card { font-size: 13px; line-height: 20px; padding: 14px 16px; border-radius: var(--dsw-radius-xl, 12px); background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); border: 0.5px solid var(--dsw-alias-settings-card-stroke, transparent); }
78
+ .hf-notice { margin: 16px 0 0; padding: 9px 12px; border-radius: var(--dsw-radius-md, 8px); font-size: 13px; line-height: 20px; white-space: pre-wrap; background: var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2)); }
79
+ .hf-notice[data-kind='error'] { color: var(--dsw-alias-state-error-primary); }
80
+ .hf-notice-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
81
+ .hf-empty { padding: 20px 0; font-size: 13px; color: var(--dsw-alias-label-tertiary); }
82
+ .hf-facts { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; margin: 0; }
83
+ .hf-facts dt, .hf-facts dd { margin: 0; padding: 9px 0; border-top: 0.5px solid var(--dsw-alias-border-l3); font-size: 13px; line-height: 20px; }
84
+ .hf-facts dt { color: var(--dsw-alias-label-secondary); }
85
+ .hf-facts dd { overflow-wrap: anywhere; }
86
+ .hf-brief { max-height: 320px; overflow: auto; margin: 10px 0; padding: 10px 12px; border-radius: var(--dsw-radius-md, 8px); background: var(--dsw-alias-bg-base); font-family: var(--dsw-font-mono, ui-monospace, monospace); font-size: 12px; line-height: 18px; white-space: pre-wrap; }
87
+ .hf-details summary { cursor: pointer; font-size: 13px; color: var(--dsw-alias-label-secondary); }
88
+ .hf-back { margin: 20px 0 4px -4px; }
89
+ `;
@@ -0,0 +1,14 @@
1
+ declare const remote: import("@deepseek-ai/dsh-typert-protocol").TypertRemoteInfo<Readonly<Record<string, import("@deepseek-ai/dsh-typert-protocol").TypertRemoteMethod<object, unknown, "unary", never, unknown> | import("@deepseek-ai/dsh-typert-protocol").TypertRemoteMethod<object, unknown, "stream", unknown, unknown>>>>;
2
+ export declare const TYPERT_REMOTE: import("@deepseek-ai/dsh-typert-protocol").TypertRemoteInfo<Readonly<Record<string, import("@deepseek-ai/dsh-typert-protocol").TypertRemoteMethod<object, unknown, "unary", never, unknown> | import("@deepseek-ai/dsh-typert-protocol").TypertRemoteMethod<object, unknown, "stream", unknown, unknown>>>>;
3
+ export default remote;
4
+ /** Set by the plugin body once `$mount` registered the namespace. */
5
+ export declare function setMountedRemote(value: unknown): void;
6
+ export declare function setMountedRemoteError(error: unknown): void;
7
+ /** Why the namespace could not mount, when known. */
8
+ export declare function mountedRemoteError(): string | undefined;
9
+ /** Call one workbench method; a failure throws an Error carrying the Host's reason. */
10
+ export declare function call<T>(method: string, request?: Record<string, unknown>): Promise<T>;
11
+ /** Open one workbench stream; dispose the handle to stop it. */
12
+ export declare function stream<T>(method: string, request: Record<string, unknown>): Promise<AsyncIterable<T> & {
13
+ dispose(): void;
14
+ }>;