@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,159 @@
1
+ /**
2
+ * The workbench's plain-language view: for each harness (Claude Code, Codex,
3
+ * OpenCode) the person's plugins and own assets, and for each part one of
4
+ * five states with the reason. Levels, plans and receipts stay in the
5
+ * details; this is what a person who never heard of them reads.
6
+ *
7
+ * | State | When |
8
+ * | --- | --- |
9
+ * | `works` | set up in DSH (or covered by an installed adapter) with nothing known missing; `checked` says whether a run here was observed |
10
+ * | `partial` | set up, but something it uses does not carry over, or a run of it failed in part |
11
+ * | `needs-port` | DSH has no equivalent; DSH's creation mode can write an adapter from its brief |
12
+ * | `unsupported` | DSH has no equivalent and none can be written from what the plugin declares |
13
+ * | `failed` | setting it up or running it failed |
14
+ * | `inactive` | the part of Harness Forge that runs it is switched off |
15
+ * | `off` | the person switched this part off |
16
+ *
17
+ * A reason is a code the browser words in the person's language, plus the
18
+ * specifics (event names, the error) as they are. A plugin not migrated yet
19
+ * shows the states its parts would have, predicted from its scan.
20
+ * @module @kirkchinese/harness-forge
21
+ */
22
+ import { adapterPackageName, assess, dialects } from '@kirkchinese/harness-forge-core';
23
+ /** The installed adapter that covers a part: one declaring it in `harnessForge.ports`, or named for it (`adapterPackageName`). */
24
+ export function coveringAdapter(plugin, component, adapters) {
25
+ return adapters.find(adapter => adapter.name === adapterPackageName(plugin, component) || adapter.ports.some(port => port.plugin === plugin.name && port.component === component.name))?.name;
26
+ }
27
+ /** Harnesses always shown, found or not; other dialects only when they found something. */
28
+ const ALWAYS_SHOWN = new Set(['claude-code', 'codex', 'opencode']);
29
+ function emptyCounts() {
30
+ return { works: 0, partial: 0, 'needs-port': 0, unsupported: 0, failed: 0, inactive: 0, off: 0 };
31
+ }
32
+ /** The specifics after "…: " in a gap summary (event or handler names), else the summary. */
33
+ function specifics(summary) {
34
+ const at = summary.indexOf(': ');
35
+ return at >= 0 ? summary.slice(at + 2) : summary;
36
+ }
37
+ function reasonOf(gap) {
38
+ switch (gap.kind) {
39
+ case 'unsupported-event': return { code: 'events-never-raised', detail: specifics(gap.summary) };
40
+ case 'semantic-difference': return gap.id.endsWith(':output-style') ? { code: 'output-style', detail: '' } : { code: 'cannot-block', detail: specifics(gap.summary) };
41
+ case 'unsupported-handler': return { code: 'handlers-inert', detail: specifics(gap.summary) };
42
+ case 'missing-host-api': return { code: 'experimental-runtime', detail: gap.detail };
43
+ case 'ui-surface': return { code: 'no-equivalent-ui', detail: '' };
44
+ case 'unsupported-component': return { code: 'not-mapped', detail: gap.summary.replace(/ is not mapped to DSH$/u, '') };
45
+ case 'unsupported-transport': return { code: 'unknown-transport', detail: '' };
46
+ case 'runtime-failure': return { code: 'setup-failed', detail: gap.summary };
47
+ default: return { code: 'other', detail: gap.summary };
48
+ }
49
+ }
50
+ /** Gaps an adapter written in DSH's creation mode can close. */
51
+ function portable(gap) {
52
+ return gap.kind === 'ui-surface' || gap.kind === 'unsupported-component' || gap.kind === 'unsupported-event' || gap.kind === 'unsupported-handler';
53
+ }
54
+ /** The state of one part, from what happened when it was set up and run (or, before migration, from its gaps). */
55
+ export function partOf(component, gaps, outcome, adapter, off = false) {
56
+ const own = gaps.filter(gap => gap.componentId === component.id && gap.kind !== 'license' && gap.kind !== 'runtime-failure');
57
+ const base = { id: component.id, kind: component.kind, name: component.name };
58
+ if (off)
59
+ return { ...base, state: 'off', checked: false, reasons: [] };
60
+ const portGap = own.find(portable)?.id;
61
+ const port = portGap !== undefined ? { portGap } : {};
62
+ // An installed adapter brings the part; nothing here has seen it run, so it is not `checked`.
63
+ if (adapter !== undefined)
64
+ return { ...base, state: 'works', checked: false, reasons: [], adapter };
65
+ // A Codex app is a connector OpenAI hosts and signs in to; nothing local can stand in for it.
66
+ if (component.kind === 'other' && component.originalKind === 'app-connector') {
67
+ return { ...base, state: 'unsupported', checked: false, reasons: [{ code: 'hosted-connector', detail: '' }] };
68
+ }
69
+ // The detail is the row that is off (`skills`, `mcp`, …), for the browser to name.
70
+ if (outcome?.status === 'inactive')
71
+ return { ...base, state: 'inactive', checked: false, reasons: [{ code: 'row-off', detail: /the (\S+) row is off/u.exec(outcome.message ?? '')?.[1] ?? '' }] };
72
+ const observations = outcome?.observations ?? [];
73
+ const failedRuns = observations.filter(item => !item.ok);
74
+ if (outcome?.status === 'failed') {
75
+ // Failed when set up (no runs recorded), or failed in its runs: some of them (partly works) or all (error).
76
+ if (failedRuns.length === 0)
77
+ return { ...base, state: 'failed', checked: true, reasons: [{ code: 'setup-failed', detail: outcome.message ?? '' }], ...port };
78
+ const runReasons = failedRuns.map(item => ({ code: 'run-failed', detail: item.detail ?? item.signal }));
79
+ return { ...base, state: failedRuns.length < observations.length ? 'partial' : 'failed', checked: true, reasons: runReasons, ...port };
80
+ }
81
+ const blocking = own.find(gap => gap.kind === 'ui-surface' || gap.kind === 'unsupported-component' || gap.kind === 'unsupported-transport');
82
+ if (blocking !== undefined || outcome?.status === 'skipped') {
83
+ const reasons = blocking !== undefined ? [reasonOf(blocking)] : [{ code: 'other', detail: outcome?.message ?? '' }];
84
+ return { ...base, state: portGap !== undefined ? 'needs-port' : 'unsupported', checked: false, reasons, ...port };
85
+ }
86
+ const verified = outcome?.status === 'verified';
87
+ // A verified code runtime has shown the API it needs is there.
88
+ const reasons = own.filter(gap => !(verified && gap.kind === 'missing-host-api')).map(reasonOf);
89
+ if (reasons.length > 0)
90
+ return { ...base, state: 'partial', checked: verified, reasons, ...port };
91
+ return { ...base, state: 'works', checked: verified, reasons: [] };
92
+ }
93
+ /** One plugin or own-assets root, installed (with outcomes) or only discovered. */
94
+ export function itemOf(plugin, record, adapters = []) {
95
+ const gaps = record?.compat?.gaps ?? assess(plugin).gaps;
96
+ const outcomes = new Map((record?.outcomes ?? []).map(outcome => [outcome.componentId, outcome]));
97
+ const coveredBy = (component) => coveringAdapter(plugin, component, adapters);
98
+ const disabled = new Set(record?.disabled ?? []);
99
+ const parts = plugin.components.map(component => partOf(component, gaps, outcomes.get(component.id), coveredBy(component), disabled.has(component.id)));
100
+ const counts = emptyCounts();
101
+ for (const part of parts)
102
+ counts[part.state]++;
103
+ return {
104
+ id: plugin.id,
105
+ name: plugin.name,
106
+ source: plugin.source,
107
+ root: plugin.root,
108
+ own: plugin.manifest['scope'] === 'user',
109
+ installed: record !== undefined,
110
+ ...(plugin.version !== undefined ? { version: plugin.version } : {}),
111
+ parts,
112
+ counts,
113
+ checked: parts.filter(part => part.state === 'works' && part.checked).length,
114
+ };
115
+ }
116
+ /** An installed plugin whose files can no longer be read: every recorded part is an error, with the reason. */
117
+ export function unreadableItemOf(record, error) {
118
+ const parts = record.components.map((component, index) => ({
119
+ id: `${record.id}:${String(index)}`,
120
+ kind: component.kind,
121
+ name: component.name,
122
+ state: 'failed',
123
+ checked: true,
124
+ reasons: [{ code: 'unreadable', detail: error }],
125
+ }));
126
+ const counts = emptyCounts();
127
+ counts.failed = parts.length;
128
+ return {
129
+ id: record.id,
130
+ name: record.name,
131
+ source: record.source,
132
+ root: record.root,
133
+ own: record.id.endsWith(':user'),
134
+ installed: true,
135
+ ...(record.version !== undefined ? { version: record.version } : {}),
136
+ parts,
137
+ counts,
138
+ checked: 0,
139
+ };
140
+ }
141
+ /** Group items by harness, in dialect order: own assets first, then installed plugins, then the rest by name. */
142
+ export function overviewOf(items) {
143
+ const known = dialects().map(dialect => ({ source: dialect.id, label: dialect.label }));
144
+ const unknown = [...new Set(items.map(item => item.source))].filter(source => !known.some(dialect => dialect.source === source)).map(source => ({ source, label: source }));
145
+ return {
146
+ harnesses: [...known, ...unknown].flatMap(({ source, label }) => {
147
+ const own = items.filter(item => item.source === source)
148
+ .sort((a, b) => Number(b.own) - Number(a.own) || Number(b.installed) - Number(a.installed) || a.name.localeCompare(b.name, 'en'));
149
+ if (own.length === 0 && !ALWAYS_SHOWN.has(source))
150
+ return [];
151
+ const counts = emptyCounts();
152
+ for (const item of own)
153
+ for (const state of Object.keys(counts))
154
+ counts[state] += item.counts[state];
155
+ const checked = own.reduce((sum, item) => sum + item.checked, 0);
156
+ return [{ source, label, items: own, counts, checked, toMigrate: own.filter(item => !item.installed).length }];
157
+ }),
158
+ };
159
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The workbench's whole Host surface, as Typert Remote methods under the
3
+ * `harnessCompat` namespace: the browser reaches them through DSH's own
4
+ * Remote carrier, like every DSH service, and Harness Forge registers no HTTP
5
+ * routes of its own. Each method takes at most one `request` object, so the
6
+ * Gateway's source-mode reflection maps one named wire argument and no
7
+ * parameter name can collide with a Host lookup. Method names avoid the
8
+ * browser namespace service's own members (`install`, `remove`, `has`, …). Failures are RemoteErrors
9
+ * whose message is the reason the person reads.
10
+ *
11
+ * Methods are marked with the protocol's runtime marker helper rather than
12
+ * decorator syntax so Vitest can load the Host entry without a decorator
13
+ * transform.
14
+ * @module @kirkchinese/harness-forge
15
+ */
16
+ import type { Context } from '@deepseek-ai/cordis';
17
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
18
+ import type { HarnessForge } from '../forge/service.js';
19
+ declare module '@deepseek-ai/dsh-typert-protocol' {
20
+ interface RemoteErrorDetailsMap {
21
+ /** A workbench operation failed; the message says why, for the person. */
22
+ 'harness-forge/failed': {
23
+ readonly operation: string;
24
+ };
25
+ }
26
+ }
27
+ /** What an adapter's surface shows for one session (the ui-slot template's `{ lines, at }`). */
28
+ export interface AdapterSurfaceSource {
29
+ /** `request`: what the browser half sent with it (a width, say). */
30
+ read(sessionId: string, request: Readonly<Record<string, unknown>>): unknown;
31
+ }
32
+ /** The installation service as Remote methods. */
33
+ export declare class HarnessRemoteService extends TypertRemoteService {
34
+ private readonly forge;
35
+ private readonly workbench;
36
+ private readonly adapterSurfaces;
37
+ private readonly adapterListeners;
38
+ constructor(ctx: Context, forge: HarnessForge);
39
+ /** A row's API, or a failure naming the row that is off. */
40
+ private row;
41
+ /** Run one operation; anything it throws reaches the browser with its message. */
42
+ private guard;
43
+ /** The instruction files added to the default workspace's prompt (`{ active, yieldingTo?, files }`); inactive while the context row is off. */
44
+ contextStatus(): Promise<unknown>;
45
+ /** The overview, plus the workspaces of open sessions with their trust and the project parts that wait for it. */
46
+ overview(): Promise<unknown>;
47
+ /** A workspace's trust (`{ workspace, trusted, sources, waiting }`): its project parts that run code wait until it is trusted. */
48
+ workspaceTrust(request: Record<string, unknown>): Promise<unknown>;
49
+ /**
50
+ * Trust (or stop trusting) a workspace in Harness Forge; returns once open sessions in it have mounted or withdrawn what changed
51
+ * (`{ decision, stillLive: [{ componentId, reason }] }`: the parts whose withdrawal failed are still live, and calling it again retries).
52
+ */
53
+ trustWorkspace(request: Record<string, unknown>): Promise<unknown>;
54
+ /** The workspaces Harness Forge holds a trust decision on (`{ workspaces: [{ workspace, trusted, sources, dismissed, trustedAt?, dismissedAt? }] }`): trusted here, or dismissed with "Not now". */
55
+ trustDecisions(): Promise<unknown>;
56
+ /** Hide (or show again) a workspace's trust banner; trusts nothing. */
57
+ dismissTrust(request: Record<string, unknown>): Promise<unknown>;
58
+ private trustOf;
59
+ discover(): Promise<unknown>;
60
+ diagnostics(): Promise<unknown>;
61
+ settings(): Promise<unknown>;
62
+ saveSettings(request: Record<string, unknown>): Promise<unknown>;
63
+ installPlugin(request: Record<string, unknown>): Promise<unknown>;
64
+ migrate(request: Record<string, unknown>): Promise<unknown>;
65
+ setPartEnabled(request: Record<string, unknown>): Promise<unknown>;
66
+ removePlugin(request: Record<string, unknown>): Promise<unknown>;
67
+ marketplaceScan(request: Record<string, unknown>): Promise<unknown>;
68
+ marketplaceInstall(request: Record<string, unknown>): Promise<unknown>;
69
+ signIns(): Promise<unknown>;
70
+ signIn(request: Record<string, unknown>): Promise<unknown>;
71
+ sessions(request: Record<string, unknown> | undefined): Promise<unknown>;
72
+ importSession(request: Record<string, unknown>): Promise<unknown>;
73
+ /**
74
+ * A session's mod drawings: the current one, then every new one, until the
75
+ * browser stops reading. Ends at once when the session's mods draw nothing.
76
+ */
77
+ modSurfaces(request: Record<string, unknown>, signal?: AbortSignal): AsyncIterable<unknown>;
78
+ modAct(request: Record<string, unknown>): Promise<unknown>;
79
+ modClose(request: Record<string, unknown>): Promise<unknown>;
80
+ modMove(request: Record<string, unknown>): Promise<unknown>;
81
+ /**
82
+ * For an adapter's Node half (not a Remote method): publish a surface its
83
+ * browser half reads through `adapterSurface`, so an adapter needs no HTTP
84
+ * route of its own. `read` gives what the surface shows for one session;
85
+ * `changed(session)` tells the browser to read again.
86
+ */
87
+ registerAdapterSurface(id: string, source: AdapterSurfaceSource): {
88
+ changed(sessionId: string): void;
89
+ dispose(): void;
90
+ };
91
+ /** What an adapter's surface shows for a session now, read once (a browser half that sets its own pace). */
92
+ adapterRead(request: Record<string, unknown>): Promise<unknown>;
93
+ /**
94
+ * What an adapter's surface shows for a session: now, then again each time
95
+ * the adapter says it changed, until the browser stops reading.
96
+ */
97
+ adapterSurface(request: Record<string, unknown>, signal?: AbortSignal): AsyncIterable<unknown>;
98
+ /**
99
+ * The task a port session starts with (the working protocol, then the part's brief), as Markdown, to preview or
100
+ * copy; `language` is the user's interface language, which the agent is told to talk in.
101
+ */
102
+ portBrief(request: Record<string, unknown>): Promise<unknown>;
103
+ /**
104
+ * The parts being ported or ported (`{ ports: [{ pluginId, componentId, state, sessionId?, verifiedAt?, adapter? }] }`,
105
+ * `state` `in-progress` or `verified`). A port whose session was deleted is dropped, so the part can be ported again.
106
+ */
107
+ portSessions(): Promise<unknown>;
108
+ /** What `harness_verify_port` answers for a part (`{ covered, checks, adapter? }`), recorded the same way. */
109
+ verifyPort(request: Record<string, unknown>): Promise<unknown>;
110
+ /**
111
+ * Port one part of a plugin: start a session in DSH's creation mode working
112
+ * on its task, in the given Workspace (`workspaceId`) or directory (`cwd`),
113
+ * and record it as the part's port session.
114
+ */
115
+ portGap(request: Record<string, unknown>): Promise<unknown>;
116
+ }
117
+ /** The Remote methods and whether each streams; the client contribution mirrors this list. */
118
+ export declare const REMOTE_METHODS: ReadonlyArray<readonly [string, 'unary' | 'stream', boolean]>;