omnicell-router 0.1.0 → 0.2.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 (212) hide show
  1. package/RELEASING.md +238 -238
  2. package/RELEASING.zh-CN.md +230 -230
  3. package/backend/dist/capture/recorder.js +2 -1
  4. package/backend/dist/cli/clients/base.js +8 -16
  5. package/backend/dist/cli/clients/dsh.js +8 -16
  6. package/backend/dist/cli/clients/pi.js +16 -9
  7. package/backend/dist/cli/types.d.ts +5 -0
  8. package/backend/dist/config/env.js +2 -1
  9. package/backend/dist/config/index.js +2 -0
  10. package/backend/dist/config/types.d.ts +23 -0
  11. package/backend/dist/harness/adapters/amp.d.ts +2 -0
  12. package/backend/dist/harness/adapters/amp.js +7 -0
  13. package/backend/dist/harness/adapters/claude.d.ts +2 -0
  14. package/backend/dist/harness/adapters/claude.js +7 -0
  15. package/backend/dist/harness/adapters/cline.d.ts +2 -0
  16. package/backend/dist/harness/adapters/cline.js +6 -0
  17. package/backend/dist/harness/adapters/codex.d.ts +2 -0
  18. package/backend/dist/harness/adapters/codex.js +6 -0
  19. package/backend/dist/harness/adapters/cursor.d.ts +5 -0
  20. package/backend/dist/harness/adapters/cursor.js +10 -0
  21. package/backend/dist/harness/adapters/declarative.d.ts +62 -0
  22. package/backend/dist/harness/adapters/declarative.js +202 -0
  23. package/backend/dist/harness/adapters/dsh.d.ts +5 -0
  24. package/backend/dist/harness/adapters/dsh.js +6 -0
  25. package/backend/dist/harness/adapters/gemini-cli.d.ts +2 -0
  26. package/backend/dist/harness/adapters/gemini-cli.js +7 -0
  27. package/backend/dist/harness/adapters/github-copilot.d.ts +5 -0
  28. package/backend/dist/harness/adapters/github-copilot.js +10 -0
  29. package/backend/dist/harness/adapters/index.d.ts +44 -0
  30. package/backend/dist/harness/adapters/index.js +99 -0
  31. package/backend/dist/harness/adapters/opencode.d.ts +2 -0
  32. package/backend/dist/harness/adapters/opencode.js +55 -0
  33. package/backend/dist/harness/adapters/pi.d.ts +1 -0
  34. package/backend/dist/harness/adapters/pi.js +22 -0
  35. package/backend/dist/harness/adapters/skills-paths.d.ts +15 -0
  36. package/backend/dist/harness/adapters/skills-paths.js +17 -0
  37. package/backend/dist/harness/adapters/types.d.ts +174 -0
  38. package/backend/dist/harness/adapters/types.js +12 -0
  39. package/backend/dist/harness/adapters/universal.d.ts +6 -0
  40. package/backend/dist/harness/adapters/universal.js +10 -0
  41. package/backend/dist/harness/adapters/windsurf.d.ts +2 -0
  42. package/backend/dist/harness/adapters/windsurf.js +10 -0
  43. package/backend/dist/harness/adapters/zed.d.ts +2 -0
  44. package/backend/dist/harness/adapters/zed.js +6 -0
  45. package/backend/dist/harness/awesome-opencode.d.ts +40 -0
  46. package/backend/dist/harness/awesome-opencode.js +75 -0
  47. package/backend/dist/harness/browse.d.ts +202 -0
  48. package/backend/dist/harness/browse.js +1214 -0
  49. package/backend/dist/harness/catalog-npm.d.ts +59 -0
  50. package/backend/dist/harness/catalog-npm.js +145 -0
  51. package/backend/dist/harness/clawhub.d.ts +212 -0
  52. package/backend/dist/harness/clawhub.js +426 -0
  53. package/backend/dist/harness/config-file.d.ts +29 -0
  54. package/backend/dist/harness/config-file.js +35 -0
  55. package/backend/dist/harness/detail.d.ts +74 -0
  56. package/backend/dist/harness/detail.js +330 -0
  57. package/backend/dist/harness/discover.d.ts +118 -0
  58. package/backend/dist/harness/discover.js +507 -0
  59. package/backend/dist/harness/drift.d.ts +21 -0
  60. package/backend/dist/harness/drift.js +25 -0
  61. package/backend/dist/harness/hash.d.ts +10 -0
  62. package/backend/dist/harness/hash.js +63 -0
  63. package/backend/dist/harness/hosts.d.ts +18 -0
  64. package/backend/dist/harness/hosts.js +15 -0
  65. package/backend/dist/harness/install.d.ts +88 -0
  66. package/backend/dist/harness/install.js +301 -0
  67. package/backend/dist/harness/inventory.d.ts +10 -0
  68. package/backend/dist/harness/inventory.js +198 -0
  69. package/backend/dist/harness/ledger.d.ts +39 -0
  70. package/backend/dist/harness/ledger.js +83 -0
  71. package/backend/dist/harness/maintenance.d.ts +115 -0
  72. package/backend/dist/harness/maintenance.js +603 -0
  73. package/backend/dist/harness/manifest.d.ts +31 -0
  74. package/backend/dist/harness/manifest.js +234 -0
  75. package/backend/dist/harness/net.d.ts +86 -0
  76. package/backend/dist/harness/net.js +113 -0
  77. package/backend/dist/harness/opencode-cafe.d.ts +40 -0
  78. package/backend/dist/harness/opencode-cafe.js +85 -0
  79. package/backend/dist/harness/opencode-ecosystem.d.ts +34 -0
  80. package/backend/dist/harness/opencode-ecosystem.js +246 -0
  81. package/backend/dist/harness/pi-dev.d.ts +81 -0
  82. package/backend/dist/harness/pi-dev.js +187 -0
  83. package/backend/dist/harness/probe.d.ts +33 -0
  84. package/backend/dist/harness/probe.js +85 -0
  85. package/backend/dist/harness/registry.d.ts +2 -0
  86. package/backend/dist/harness/registry.js +26 -0
  87. package/backend/dist/harness/scopes.d.ts +21 -0
  88. package/backend/dist/harness/scopes.js +22 -0
  89. package/backend/dist/harness/skill-md.d.ts +18 -0
  90. package/backend/dist/harness/skill-md.js +71 -0
  91. package/backend/dist/harness/skills-sh.d.ts +109 -0
  92. package/backend/dist/harness/skills-sh.js +178 -0
  93. package/backend/dist/harness/smithery.d.ts +64 -0
  94. package/backend/dist/harness/smithery.js +146 -0
  95. package/backend/dist/harness/sources/awesome-opencode.d.ts +11 -0
  96. package/backend/dist/harness/sources/awesome-opencode.js +39 -0
  97. package/backend/dist/harness/sources/clawhub.d.ts +2 -0
  98. package/backend/dist/harness/sources/clawhub.js +83 -0
  99. package/backend/dist/harness/sources/github.d.ts +9 -0
  100. package/backend/dist/harness/sources/github.js +202 -0
  101. package/backend/dist/harness/sources/mcp-official.d.ts +2 -0
  102. package/backend/dist/harness/sources/mcp-official.js +110 -0
  103. package/backend/dist/harness/sources/npm.d.ts +2 -0
  104. package/backend/dist/harness/sources/npm.js +152 -0
  105. package/backend/dist/harness/sources/opencode-cafe.d.ts +11 -0
  106. package/backend/dist/harness/sources/opencode-cafe.js +41 -0
  107. package/backend/dist/harness/sources/smithery.d.ts +2 -0
  108. package/backend/dist/harness/sources/smithery.js +81 -0
  109. package/backend/dist/harness/spi.d.ts +98 -0
  110. package/backend/dist/harness/spi.js +8 -0
  111. package/backend/dist/harness/stars.d.ts +70 -0
  112. package/backend/dist/harness/stars.js +202 -0
  113. package/backend/dist/harness/translation.d.ts +142 -0
  114. package/backend/dist/harness/translation.js +567 -0
  115. package/backend/dist/harness/tree.d.ts +13 -0
  116. package/backend/dist/harness/tree.js +19 -0
  117. package/backend/dist/harness/types.d.ts +286 -0
  118. package/backend/dist/harness/types.js +8 -0
  119. package/backend/dist/harness/writers/extension.d.ts +116 -0
  120. package/backend/dist/harness/writers/extension.js +219 -0
  121. package/backend/dist/harness/writers/mcp.d.ts +72 -0
  122. package/backend/dist/harness/writers/mcp.js +195 -0
  123. package/backend/dist/harness/writers/skill.d.ts +60 -0
  124. package/backend/dist/harness/writers/skill.js +146 -0
  125. package/backend/dist/opencode/agents.d.ts +5 -0
  126. package/backend/dist/opencode/agents.js +10 -1
  127. package/backend/dist/opencode/catalog/cache.js +2 -1
  128. package/backend/dist/opencode/catalog/logos.js +2 -1
  129. package/backend/dist/opencode/catalog/ocr-store.js +2 -1
  130. package/backend/dist/opencode/catalog/overrides-store.js +2 -1
  131. package/backend/dist/opencode/credentials/factory.js +10 -27
  132. package/backend/dist/opencode/credentials/ocr-store.js +2 -1
  133. package/backend/dist/opencode/provider-defs.js +2 -1
  134. package/backend/dist/opencode/user-config.js +8 -16
  135. package/backend/dist/providers/registry.d.ts +15 -4
  136. package/backend/dist/providers/registry.js +29 -5
  137. package/backend/dist/providers/virtual-meta.d.ts +13 -0
  138. package/backend/dist/providers/virtual-meta.js +18 -0
  139. package/backend/dist/quota/store.js +2 -1
  140. package/backend/dist/resilience/breaker-state.js +2 -1
  141. package/backend/dist/resilience/credential-state.js +2 -1
  142. package/backend/dist/routes/console.js +137 -15
  143. package/backend/dist/routes/harness.d.ts +2 -0
  144. package/backend/dist/routes/harness.js +622 -0
  145. package/backend/dist/server.js +4 -0
  146. package/backend/dist/session/session-manager.js +2 -1
  147. package/backend/dist/surfaces/systemone-probe.d.ts +25 -0
  148. package/backend/dist/surfaces/systemone-probe.js +74 -0
  149. package/backend/dist/utils/atomic-write.d.ts +12 -0
  150. package/backend/dist/utils/atomic-write.js +29 -0
  151. package/bin/ocr.js +2 -2
  152. package/frontend/dist/assets/{index-DEo2iAT7.css → index-1o7qI-KJ.css} +1 -1
  153. package/frontend/dist/assets/index-DvXKvNxl.js +962 -0
  154. package/frontend/dist/index.html +2 -2
  155. package/package.json +87 -87
  156. package/backend/dist/budget/budget-manager.d.ts +0 -25
  157. package/backend/dist/budget/budget-manager.js +0 -54
  158. package/backend/dist/config/governance-limits.d.ts +0 -68
  159. package/backend/dist/config/governance-limits.js +0 -261
  160. package/backend/dist/flywheel/collector.d.ts +0 -74
  161. package/backend/dist/flywheel/collector.js +0 -235
  162. package/backend/dist/flywheel/dataset.d.ts +0 -130
  163. package/backend/dist/flywheel/dataset.js +0 -638
  164. package/backend/dist/flywheel/decision-capture.d.ts +0 -68
  165. package/backend/dist/flywheel/decision-capture.js +0 -85
  166. package/backend/dist/flywheel/prune.d.ts +0 -133
  167. package/backend/dist/flywheel/prune.js +0 -495
  168. package/backend/dist/flywheel/schema.d.ts +0 -108
  169. package/backend/dist/flywheel/schema.js +0 -117
  170. package/backend/dist/flywheel/trainer.d.ts +0 -84
  171. package/backend/dist/flywheel/trainer.js +0 -198
  172. package/backend/dist/opencode/catalog/custom-store.d.ts +0 -50
  173. package/backend/dist/opencode/catalog/custom-store.js +0 -144
  174. package/backend/dist/opencode/credentials/push.d.ts +0 -38
  175. package/backend/dist/opencode/credentials/push.js +0 -116
  176. package/backend/dist/opencode/credentials/reconcile.d.ts +0 -49
  177. package/backend/dist/opencode/credentials/reconcile.js +0 -216
  178. package/backend/dist/opencode/sync.d.ts +0 -29
  179. package/backend/dist/opencode/sync.js +0 -186
  180. package/backend/dist/pipeline/account-selection.d.ts +0 -101
  181. package/backend/dist/pipeline/account-selection.js +0 -112
  182. package/backend/dist/providers/systemone.d.ts +0 -29
  183. package/backend/dist/providers/systemone.js +0 -170
  184. package/backend/dist/ratelimit/duration.d.ts +0 -24
  185. package/backend/dist/ratelimit/duration.js +0 -43
  186. package/backend/dist/ratelimit/governance-runtime.d.ts +0 -121
  187. package/backend/dist/ratelimit/governance-runtime.js +0 -183
  188. package/backend/dist/ratelimit/index.d.ts +0 -4
  189. package/backend/dist/ratelimit/index.js +0 -4
  190. package/backend/dist/ratelimit/limiter.d.ts +0 -157
  191. package/backend/dist/ratelimit/limiter.js +0 -244
  192. package/backend/dist/ratelimit/sliding-window-counter.d.ts +0 -63
  193. package/backend/dist/ratelimit/sliding-window-counter.js +0 -103
  194. package/backend/dist/ratelimit/subject.d.ts +0 -26
  195. package/backend/dist/ratelimit/subject.js +0 -28
  196. package/backend/dist/resilience/account-state.d.ts +0 -84
  197. package/backend/dist/resilience/account-state.js +0 -228
  198. package/backend/dist/router/layer1-classifier.d.ts +0 -111
  199. package/backend/dist/router/layer1-classifier.js +0 -467
  200. package/backend/dist/router/layer2-judge.d.ts +0 -111
  201. package/backend/dist/router/layer2-judge.js +0 -373
  202. package/backend/dist/router/retry-escalation.d.ts +0 -89
  203. package/backend/dist/router/retry-escalation.js +0 -99
  204. package/backend/dist/routes/flywheel.d.ts +0 -3
  205. package/backend/dist/routes/flywheel.js +0 -268
  206. package/backend/dist/routes/systemone.d.ts +0 -3
  207. package/backend/dist/routes/systemone.js +0 -90
  208. package/backend/dist/surfaces/governance-envelope.d.ts +0 -34
  209. package/backend/dist/surfaces/governance-envelope.js +0 -47
  210. package/backend/dist/utils/token-estimator.d.ts +0 -7
  211. package/backend/dist/utils/token-estimator.js +0 -20
  212. package/frontend/dist/assets/index-nwgWkmU1.js +0 -840
@@ -0,0 +1,22 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { defineHost } from './declarative.js';
4
+ import { UNIVERSAL_SKILLS } from './skills-paths.js';
5
+ /**
6
+ * Pi — shared skills directory + package-manager extension landing (ADR-0015 §D8.9).
7
+ *
8
+ * `pi install npm:<spec>` writes `settings.json` `packages[]` (the declaration the runtime itself
9
+ * reads), resolves the package under `<dir>/npm` (whose lock file answers the exact version), and
10
+ * loads loose `extensions/*.ts` files from disk with no package at all. All three surfaces are
11
+ * declared here, because all three are things the runtime loads and the console must be able to show.
12
+ */
13
+ const AGENT_DIR = path.join(os.homedir(), '.pi', 'agent');
14
+ export const piAdapter = defineHost('pi', {
15
+ skills: { global: UNIVERSAL_SKILLS.global, project: UNIVERSAL_SKILLS.project, readsUniversal: true },
16
+ ext: {
17
+ subprocess: 'pi',
18
+ declared: { global: path.join(AGENT_DIR, 'settings.json'), key: 'packages' },
19
+ looseDir: { global: path.join(AGENT_DIR, 'extensions') },
20
+ lock: path.join(AGENT_DIR, 'npm', 'package-lock.json'),
21
+ },
22
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shared path primitives for host adapters (leaf module — imports nothing from `harness/`).
3
+ *
4
+ * These two facts are cross-host: the user's home, the XDG config root, and the cross-agent
5
+ * `.agents/skills` directory that several runtimes read directly. They live here, declared exactly
6
+ * once, because `universal` owns the directory and every `readsUniversal` host REFERENCES it instead
7
+ * of re-declaring the path (a second literal would be the drift twin AGENTS.md forbids).
8
+ */
9
+ export declare const home: () => string;
10
+ export declare const xdgConfig: () => string;
11
+ /** The cross-agent skills directory — owned by `universal`, read by every `readsUniversal` host. */
12
+ export declare const UNIVERSAL_SKILLS: {
13
+ readonly global: string;
14
+ readonly project: string;
15
+ };
@@ -0,0 +1,17 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ /**
4
+ * Shared path primitives for host adapters (leaf module — imports nothing from `harness/`).
5
+ *
6
+ * These two facts are cross-host: the user's home, the XDG config root, and the cross-agent
7
+ * `.agents/skills` directory that several runtimes read directly. They live here, declared exactly
8
+ * once, because `universal` owns the directory and every `readsUniversal` host REFERENCES it instead
9
+ * of re-declaring the path (a second literal would be the drift twin AGENTS.md forbids).
10
+ */
11
+ export const home = () => os.homedir();
12
+ export const xdgConfig = () => process.env.XDG_CONFIG_HOME || path.join(home(), '.config');
13
+ /** The cross-agent skills directory — owned by `universal`, read by every `readsUniversal` host. */
14
+ export const UNIVERSAL_SKILLS = {
15
+ global: path.join(home(), '.agents', 'skills'),
16
+ project: path.join('.agents', 'skills'),
17
+ };
@@ -0,0 +1,174 @@
1
+ import type { ExtDiscoveryOrigin, HarnessHostId, HarnessScope, ResolvedRoot } from '../types.js';
2
+ /**
3
+ * Host adaptation surface — one module per harness, capabilities as SEPARATE interfaces
4
+ * (ADR-0015 §D3 R3, §D8.8).
5
+ *
6
+ * WHY capabilities instead of one fat `HarnessHost` with `list/install/uninstall × skill|mcp|ext`:
7
+ * the capability matrix is wildly asymmetric. In the current catalog twelve hosts have a skills
8
+ * location, ONE has a verified MCP landing (opencode) and TWO have a verified extension landing
9
+ * (opencode, pi). A nine-method flat interface would be 117 slots of which ~72 are `throw new
10
+ * Error('unsupported')`, and a caller still cannot tell "this host cannot do MCP" from "this host
11
+ * forgot to implement it". Capability interfaces make absence a TYPE fact, not a runtime throw.
12
+ *
13
+ * WHY installation verbs are NOT here: install/uninstall are one pipeline — plan → confirm → apply →
14
+ * ledger → claims (ADR-0015 gates 2/3) — implemented once per KIND in `writers/`, not once per host.
15
+ * An adapter that owned `installExtension` would either duplicate that pipeline thirteen times or
16
+ * become a forwarder. The split is: **the adapter answers WHERE, the writer answers HOW.**
17
+ *
18
+ * WHY skills are not a host capability at all: a skill lands in a DIRECTORY, and one directory is
19
+ * read by up to nine hosts (`readsUniversal` / `skillOwner`). "Install this skill into this host"
20
+ * would invite writing the same tree nine times; skills live on the location level
21
+ * (`skillRoots` / `skillTarget` on this interface, aggregated by `skillLocationRoots`).
22
+ *
23
+ * WHY one adapter per VERSION is not modelled: `opencode` v1 and v2 differ in landing SPELLINGS
24
+ * (`opencode.json`/`plugin`/`plugin/` vs `opencode.jsonc`/`plugins`/`plugins/`), not in a proven
25
+ * plugin-API split. Extension identity is `extension:<harness>:<canonicalKey>` (§D7), so two adapter
26
+ * ids would split one installed plugin into two artifacts — and during a mid-major migration the
27
+ * same machine carries both spellings at once and would report the plugin twice. The version ladder
28
+ * therefore lives INSIDE one adapter (`ExtensionSpec` path lists), and only a proven API incompatibility
29
+ * would be a reason to change identity — which is an ADR-0015 §D7 amendment, not an adapter detail.
30
+ */
31
+ /**
32
+ * Where a discovered row was read from — the runtime's own record, never a manifest entry.
33
+ * (Re-exported here so a host adapter can name its source shape without importing the scanner.)
34
+ */
35
+ export type ExtSourceOrigin = ExtDiscoveryOrigin;
36
+ /** One place a host records its own extensions, as the scan reads it. */
37
+ export interface ExtSource {
38
+ host: HarnessHostId;
39
+ scope: HarnessScope;
40
+ origin: ExtSourceOrigin;
41
+ kind: 'config-array' | 'declared' | 'loose-dir';
42
+ /** The config/declaration file, or the loose-file directory. */
43
+ path: string;
44
+ /**
45
+ * Container key(s) inside `path` — `plugin`/`plugins` for a config array, `packages` for a
46
+ * declaration. A list because a runtime may have renamed the key between majors.
47
+ */
48
+ key?: string | string[];
49
+ /** Lock file resolving this source's `npm:` specs to the version actually installed. */
50
+ lockPath?: string;
51
+ }
52
+ /** Everything an adapter needs to answer for a scope. */
53
+ export interface AdapterContext {
54
+ /** Project root a project-scope landing resolves against (the gateway process cwd by default). */
55
+ projectRoot: string;
56
+ }
57
+ /**
58
+ * Data an extension host declares about its landing — paths are `string | string[]`: a list is a
59
+ * VERSION LADDER (newest spelling first), never a duplicate, so a machine that migrated mid-major
60
+ * still resolves.
61
+ */
62
+ export interface ExtensionSpec {
63
+ /** Array-shaped config landing: every file the runtime reads, newest spelling first. */
64
+ configGlobal?: string | string[];
65
+ configProject?: string | string[];
66
+ /** Container key the host's OWN schema names — the write default. */
67
+ container?: string;
68
+ /** Alternate container spellings an older/newer runtime reads (`plugin` vs `plugins`). */
69
+ containerAliases?: string[];
70
+ /** Declaration file a package-manager landing records itself in. */
71
+ declared?: {
72
+ global: string | string[];
73
+ project?: string | string[];
74
+ key: string;
75
+ };
76
+ /** Directory of loose extension files the runtime loads directly. */
77
+ looseDir?: {
78
+ global: string | string[];
79
+ project?: string | string[];
80
+ };
81
+ /** Lock file resolving `npm:` specs to the exact version actually installed. */
82
+ lock?: string;
83
+ /** Package-manager command that owns the install (`pi install …`), when the host is one. */
84
+ subprocess?: string;
85
+ }
86
+ /** Where an install writes, or why it refuses. */
87
+ export type ExtensionWriteTarget = {
88
+ ok: true;
89
+ op: 'config';
90
+ path: string;
91
+ container: string;
92
+ } | {
93
+ ok: true;
94
+ op: 'subprocess';
95
+ command: string;
96
+ } | {
97
+ ok: false;
98
+ reason: string;
99
+ };
100
+ /**
101
+ * The minimum every host answers: its identity, plus the env var that relocates its config root
102
+ * (`OPENCODE_CONFIG_DIR`, `DSH_HOME`) when it honours one. Present even for hosts whose only wired
103
+ * capability is skills — "this host exists and declares no MCP/extension landing" is a measured
104
+ * statement, and the console renders it as such instead of an empty row.
105
+ */
106
+ export interface HostAdapter {
107
+ readonly id: HarnessHostId;
108
+ /** Env var that relocates this runtime's config root, when it honours one. */
109
+ readonly configRootEnv?: string;
110
+ }
111
+ /** Where a host's skills land: one directory per scope, relocated by the host's env root when set. */
112
+ export interface SkillsSpec {
113
+ global: string;
114
+ project: string;
115
+ /** True when the runtime also reads the shared cross-agent `.agents/skills` directory. */
116
+ readsUniversal?: boolean;
117
+ }
118
+ /** A host that loads agent skills from directories it reads. */
119
+ export interface SkillsHost extends HostAdapter {
120
+ /**
121
+ * Candidate skills roots for one scope, highest precedence first. Global scope may include the
122
+ * cross-agent `.agents/skills` directory when the runtime reads it (`readsUniversal`); project
123
+ * scope is a single directory, because no runtime reads a second project root.
124
+ */
125
+ skillRoots(ctx: AdapterContext, scope: HarnessScope): ResolvedRoot[];
126
+ /** Where one skill NAME lands in this host, refusing anything that escapes its root. */
127
+ skillTarget(ctx: AdapterContext, scope: HarnessScope, name: string): {
128
+ ok: true;
129
+ root: ResolvedRoot;
130
+ path: string;
131
+ } | {
132
+ ok: false;
133
+ reason: string;
134
+ };
135
+ /** True when this runtime also reads the shared cross-agent skills directory. */
136
+ readonly readsUniversalSkills: boolean;
137
+ }
138
+ /** A host that loads extension code and records it somewhere (config array or its own store). */
139
+ export interface ExtensionHost extends HostAdapter {
140
+ /** Every place this host records its own extensions for one scope. */
141
+ readSources(ctx: AdapterContext, scope: HarnessScope): ExtSource[];
142
+ /** Container keys the host's array record may live under, write default first. */
143
+ containers(): string[];
144
+ /** Declaration files a package-manager install records itself in. */
145
+ declarations(): {
146
+ file: string;
147
+ key: string;
148
+ }[];
149
+ /** Lock file answering exact versions, when the host's package manager writes one. */
150
+ lock(): string | undefined;
151
+ /** Loose extension directories the runtime loads files from directly, for one scope. */
152
+ looseDirs(ctx: AdapterContext, scope: HarnessScope): string[];
153
+ /** Where an install for this host + scope lands (or the refusal reason). */
154
+ writeTarget(ctx: AdapterContext, scope: HarnessScope): ExtensionWriteTarget;
155
+ }
156
+ /** A host whose MCP servers merge into a config file it owns. */
157
+ export interface McpHost extends HostAdapter {
158
+ /** Container key the server entries merge into. */
159
+ readonly container: string;
160
+ /** The config file an MCP landing writes, or why this scope has none. */
161
+ configPath(ctx: AdapterContext, scope: HarnessScope): {
162
+ ok: true;
163
+ path: string;
164
+ } | {
165
+ ok: false;
166
+ reason: string;
167
+ };
168
+ }
169
+ /** Capability probe — absence is a TYPE fact, so no caller needs a try/catch around "unsupported". */
170
+ export declare function isSkillsHost(adapter: HostAdapter | undefined): adapter is SkillsHost;
171
+ /** Capability probe for the extension landing. */
172
+ export declare function isExtensionHost(adapter: HostAdapter | undefined): adapter is ExtensionHost;
173
+ /** Capability probe for the MCP landing. */
174
+ export declare function isMcpHost(adapter: HostAdapter | undefined): adapter is McpHost;
@@ -0,0 +1,12 @@
1
+ /** Capability probe — absence is a TYPE fact, so no caller needs a try/catch around "unsupported". */
2
+ export function isSkillsHost(adapter) {
3
+ return !!adapter && typeof adapter.skillRoots === 'function';
4
+ }
5
+ /** Capability probe for the extension landing. */
6
+ export function isExtensionHost(adapter) {
7
+ return !!adapter && typeof adapter.readSources === 'function';
8
+ }
9
+ /** Capability probe for the MCP landing. */
10
+ export function isMcpHost(adapter) {
11
+ return !!adapter && typeof adapter.configPath === 'function';
12
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Universal (`.agents`) — the shared cross-agent SKILLS directory other runtimes read. It owns that
3
+ * directory (the single declaration every `readsUniversal` host references) and has no MCP or
4
+ * extension landing: it is a location, not a runtime with a plugin API.
5
+ */
6
+ export declare const universalAdapter: import("./declarative.js").DefinedHost;
@@ -0,0 +1,10 @@
1
+ import { defineHost } from './declarative.js';
2
+ import { UNIVERSAL_SKILLS } from './skills-paths.js';
3
+ /**
4
+ * Universal (`.agents`) — the shared cross-agent SKILLS directory other runtimes read. It owns that
5
+ * directory (the single declaration every `readsUniversal` host references) and has no MCP or
6
+ * extension landing: it is a location, not a runtime with a plugin API.
7
+ */
8
+ export const universalAdapter = defineHost('universal', {
9
+ skills: { global: UNIVERSAL_SKILLS.global, project: UNIVERSAL_SKILLS.project, readsUniversal: true },
10
+ });
@@ -0,0 +1,2 @@
1
+ /** Windsurf — its own skills directory (project `.windsurf/skills`); no MCP or extension landing. */
2
+ export declare const windsurfAdapter: import("./declarative.js").DefinedHost;
@@ -0,0 +1,10 @@
1
+ import path from 'node:path';
2
+ import { defineHost } from './declarative.js';
3
+ import { home } from './skills-paths.js';
4
+ /** Windsurf — its own skills directory (project `.windsurf/skills`); no MCP or extension landing. */
5
+ export const windsurfAdapter = defineHost('windsurf', {
6
+ skills: {
7
+ global: path.join(home(), '.codeium', 'windsurf', 'skills'),
8
+ project: path.join('.windsurf', 'skills'),
9
+ },
10
+ });
@@ -0,0 +1,2 @@
1
+ /** Zed — reads the shared cross-agent skills directory; its extension packages are editor-built. */
2
+ export declare const zedAdapter: import("./declarative.js").DefinedHost;
@@ -0,0 +1,6 @@
1
+ import { defineHost } from './declarative.js';
2
+ import { UNIVERSAL_SKILLS } from './skills-paths.js';
3
+ /** Zed — reads the shared cross-agent skills directory; its extension packages are editor-built. */
4
+ export const zedAdapter = defineHost('zed', {
5
+ skills: { global: UNIVERSAL_SKILLS.global, project: UNIVERSAL_SKILLS.project, readsUniversal: true },
6
+ });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * awesome-opencode registry — the upstream reader.
3
+ *
4
+ * The repo publishes its catalog as a machine-readable FLAT ARRAY: `dist/registry.json`, generated by
5
+ * `scripts/export-json.js` from one YAML file per entry under `data/<category>/`. It is read through
6
+ * the GitHub contents API with the raw media type, because `raw.githubusercontent.com` resets the
7
+ * connection from this environment while `api.github.com` is the host the GitHub search adapter
8
+ * already talks to.
9
+ *
10
+ * No cache lives here on purpose: browsing caches the answered list in `browse.ts` (one upstream read
11
+ * serves every keystroke), while an install resolves ONE entry at a time and must not be answered from
12
+ * a list fetched for a different purpose. The package-identity rules live in `catalog-npm.ts`, shared
13
+ * with the other community catalog.
14
+ */
15
+ import { type FailureReason } from './net.js';
16
+ /** One entry of `dist/registry.json`, narrowed to the fields this build reads. */
17
+ export interface AwesomeEntry {
18
+ productId?: string;
19
+ type?: string;
20
+ displayName?: string;
21
+ repoUrl?: string;
22
+ tagline?: string;
23
+ description?: string;
24
+ tags?: string[];
25
+ homepageUrl?: string;
26
+ /** Free-form markdown install instructions; when present it may name the package verbatim. */
27
+ installation?: string;
28
+ }
29
+ export type AwesomeRegistryResult = {
30
+ ok: true;
31
+ entries: AwesomeEntry[];
32
+ } | {
33
+ ok: false;
34
+ code: 'unavailable' | 'upstream';
35
+ reason: FailureReason;
36
+ reasonParams?: Record<string, string>;
37
+ message: string;
38
+ };
39
+ /** Read and decode the registry. The contents API may honor `raw` or answer a base64 envelope. */
40
+ export declare function fetchAwesomeRegistry(fetchImpl?: typeof fetch): Promise<AwesomeRegistryResult>;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * awesome-opencode registry — the upstream reader.
3
+ *
4
+ * The repo publishes its catalog as a machine-readable FLAT ARRAY: `dist/registry.json`, generated by
5
+ * `scripts/export-json.js` from one YAML file per entry under `data/<category>/`. It is read through
6
+ * the GitHub contents API with the raw media type, because `raw.githubusercontent.com` resets the
7
+ * connection from this environment while `api.github.com` is the host the GitHub search adapter
8
+ * already talks to.
9
+ *
10
+ * No cache lives here on purpose: browsing caches the answered list in `browse.ts` (one upstream read
11
+ * serves every keystroke), while an install resolves ONE entry at a time and must not be answered from
12
+ * a list fetched for a different purpose. The package-identity rules live in `catalog-npm.ts`, shared
13
+ * with the other community catalog.
14
+ */
15
+ import { describeFetchFailure, fetchFailureReason, fetchWithRetry } from './net.js';
16
+ const REGISTRY_URL = 'https://api.github.com/repos/awesome-opencode/awesome-opencode/contents/dist/registry.json';
17
+ function githubHeaders() {
18
+ const token = process.env.GITHUB_TOKEN?.trim();
19
+ return {
20
+ Accept: 'application/vnd.github.raw',
21
+ 'User-Agent': 'omnicellrouter-harness',
22
+ ...(token ? { Authorization: `Bearer ${token}` } : {}),
23
+ };
24
+ }
25
+ /** Read and decode the registry. The contents API may honor `raw` or answer a base64 envelope. */
26
+ export async function fetchAwesomeRegistry(fetchImpl = fetch) {
27
+ let res;
28
+ try {
29
+ // Every failed answer is retried inside the shared policy (see `MARKET_RETRY`); a rate-limited
30
+ // answer that outlasts the retries keeps its own `rateLimited` reason below.
31
+ res = await fetchWithRetry(REGISTRY_URL, { headers: githubHeaders() }, undefined, { fetchImpl });
32
+ }
33
+ catch (e) {
34
+ return { ok: false, code: 'upstream', reason: fetchFailureReason(e), message: describeFetchFailure('GitHub API', e) };
35
+ }
36
+ if (res.status === 403 || res.status === 429) {
37
+ return {
38
+ ok: false,
39
+ code: 'unavailable',
40
+ reason: 'rateLimited',
41
+ message: 'GitHub API rate limit reached — set GITHUB_TOKEN to raise it',
42
+ };
43
+ }
44
+ if (!res.ok) {
45
+ return {
46
+ ok: false,
47
+ code: 'upstream',
48
+ reason: 'http',
49
+ reasonParams: { status: String(res.status) },
50
+ message: `GitHub returned HTTP ${res.status}`,
51
+ };
52
+ }
53
+ const text = await res.text();
54
+ let parsed;
55
+ try {
56
+ parsed = JSON.parse(text);
57
+ }
58
+ catch {
59
+ return { ok: false, code: 'upstream', reason: 'badPayload', message: 'registry.json was not JSON' };
60
+ }
61
+ // A proxy or an ignored media type can answer the contents envelope instead of the file bytes.
62
+ const envelope = parsed;
63
+ if (!Array.isArray(parsed) && typeof envelope.content === 'string' && envelope.encoding === 'base64') {
64
+ try {
65
+ parsed = JSON.parse(Buffer.from(envelope.content, 'base64').toString('utf8'));
66
+ }
67
+ catch {
68
+ return { ok: false, code: 'upstream', reason: 'badPayload', message: 'registry.json envelope did not decode to JSON' };
69
+ }
70
+ }
71
+ if (!Array.isArray(parsed)) {
72
+ return { ok: false, code: 'upstream', reason: 'badPayload', message: 'registry.json is not a flat array' };
73
+ }
74
+ return { ok: true, entries: parsed };
75
+ }
@@ -0,0 +1,202 @@
1
+ import { type FailureReason } from './net.js';
2
+ import type { HarnessKind, HarnessSourceView } from './types.js';
3
+ export interface MarketItem {
4
+ /** Stable across sources: `<sourceId>:<repo or package>`. */
5
+ id: string;
6
+ sourceId: string;
7
+ /**
8
+ * Portable install handle — what the install endpoint takes as `key`
9
+ * (`github:<owner/repo>` / `npm:<name>`). `id` carries the same value; `key` names its role.
10
+ */
11
+ key: string;
12
+ /**
13
+ * Which writer serves this row: a skill copy tree, an extension package, or an MCP server merged
14
+ * into a host's own config. It is the WRITER's kind, not the page's — an npm package reached from
15
+ * the skills page is an extension (ADR-0015 §8).
16
+ */
17
+ installKind: 'skill' | 'mcp' | 'extension';
18
+ /** Display name — the repo name, or the skill directory when a repo holds several. */
19
+ name: string;
20
+ /** `owner/repo` when the row has a GitHub project; absent for sources whose identity is only a
21
+ * package name. */
22
+ repo?: string;
23
+ description: string | null;
24
+ url: string;
25
+ /**
26
+ * GitHub stars, or `null` when this source publishes no popularity signal at all.
27
+ *
28
+ * `null` is NOT `0`: a catalog that never states a star count (npm, the Pi catalog, the community
29
+ * registries) must not claim "nobody starred this". The console renders the two differently, and a
30
+ * row may still ACQUIRE a number later — `harness/stars.ts` resolves stars on demand for the
31
+ * repositories a page references, one batched GitHub search per page.
32
+ */
33
+ stars: number | null;
34
+ /**
35
+ * The SOURCE'S OWN popularity counters, when the source has a popularity system of its own that is
36
+ * NOT GitHub stars — today only ClawHub (its own star unit, plus downloads/installs).
37
+ *
38
+ * Kept in a separate field, never folded into `stars`: the star column means "GitHub stars", and
39
+ * printing a registry rating under it would relabel one number as another (ADR-0015 §D6 — the same
40
+ * rule that keeps skills.sh's install tally out). The console labels this one with its source.
41
+ */
42
+ registryStats?: {
43
+ stars: number | null;
44
+ downloads: number | null;
45
+ installs: number | null;
46
+ };
47
+ updatedAt: string;
48
+ topics: string[];
49
+ }
50
+ export type BrowseResult = {
51
+ ok: true;
52
+ items: MarketItem[];
53
+ /** True when the source has another page for this query — the console's "next" affordance. */
54
+ hasMore: boolean;
55
+ /** Rows the source reports for this query, when it reports one. Absent = unknown, and the
56
+ * console then shows the page number without inventing a total. */
57
+ total?: number;
58
+ /**
59
+ * What `total` COUNTS. Absent means "the catalog, as far as the source can see it". `window`
60
+ * says the number is only the reachable slice — skills.sh ships a fixed 600-row board out of a
61
+ * 9 911-skill ranking, and its search caps every answer at 200 — so the console must not print it
62
+ * as the population. The pager still needs it to draw the page buttons.
63
+ */
64
+ totalScope?: 'catalog' | 'window';
65
+ /** English copy, kept as the fallback the console shows when it has no string for `noteCode`. */
66
+ note?: string;
67
+ /** Opaque identity for `note` — the console maps it to its own translation table and fills
68
+ * `noteParams` into that string. Same rule as the ratelimit ledger's `note`/`noteCode`: the
69
+ * backend states the fact, the console owns the words. */
70
+ noteCode?: HarnessNoteCode;
71
+ noteParams?: Record<string, string>;
72
+ } | {
73
+ ok: false;
74
+ code: 'unsupported_source' | 'unavailable' | 'upstream';
75
+ /** Why the read failed, in vocabulary the console translates (`harness.browseError.*`).
76
+ * `message` stays as the English fallback: an unmapped reason never shows a bare key. */
77
+ reason?: FailureReason;
78
+ reasonParams?: Record<string, string>;
79
+ message: string;
80
+ };
81
+ /** The sentences a browse adapter attaches to an answer (`noteCode`). */
82
+ export type HarnessNoteCode =
83
+ /** github — no GITHUB_TOKEN, so the anonymous search quota applies. */
84
+ 'github-anonymous'
85
+ /** npm — no query typed, so the empty-query keyword default (`{keyword}`) is what was searched. */
86
+ | 'npm-keyword'
87
+ /** npm — no query typed and this host has no tag convention, so a plain phrase (`{query}`) was
88
+ * searched: a relevance guess, not a catalog membership. */
89
+ | 'npm-default'
90
+ /** static-opencode — shipped snapshot, not a live registry. */
91
+ | 'curated'
92
+ /** awesome-opencode / opencode-cafe — rows carry no package name until install resolves it. */
93
+ | 'awesome'
94
+ /** opencode-cafe — the catalog's own count vs the plugin subset this market can install
95
+ * (`{total}` entries, `{plugins}` of them plugins). */
96
+ | 'cafe-filtered'
97
+ /** pi-dev — the catalog's own install command. */
98
+ | 'pi-dev'
99
+ /** npm — an order the registry cannot serve natively: the backend fetched a window (npm's own
100
+ * ranking) and ordered THAT (`{n}` rows), so the list is sorted server-side, not in the page. */
101
+ | 'window-sorted'
102
+ /** mcp-official — the registry lists server records, and a row installs into a client's own `mcp`
103
+ * container (an MCP server is a config member, not a package or a skills tree). */
104
+ | 'mcp-registry'
105
+ /** skills.sh — one BOARD answer: `{n}` is the size the site states for the board, read 200 rows at a
106
+ * time from its own paging endpoint. */
107
+ | 'skills-sh-board'
108
+ /** skills.sh — a full-catalog search: `{n}` is the endpoint's own match cap per query (it ignores
109
+ * paging), so a broad term stops there instead of paging into a void. */
110
+ | 'skills-sh-search'
111
+ /** smithery — the listing serves a reachable window (`{reachable}` of the `{total}` it reports). */
112
+ | 'smithery-window'
113
+ /** clawhub — the catalog endpoint's own ranking, cursor-paged and count-less. */
114
+ | 'clawhub-catalog'
115
+ /** clawhub — a full-catalog search: `{n}` is the limit one request carries (the endpoint has no
116
+ * paging parameter), so the answer is a window. */
117
+ | 'clawhub-search';
118
+ /**
119
+ * GitHub request headers — one place for the token, shared by every reader that talks to the API
120
+ * (browse and the on-demand star resolver). A second copy would drift the day one of them learns a
121
+ * new header.
122
+ */
123
+ export declare function githubHeaders(): Record<string, string>;
124
+ /** Drop the whole browse cache (tests, and any caller that cannot name one source): the TTL is a
125
+ * rate-limit shield, not a correctness contract. */
126
+ export declare function resetBrowseCache(): void;
127
+ /**
128
+ * Drop ONE source's cached pages, so the next read asks upstream again.
129
+ *
130
+ * Only an explicit operator refresh reaches here (`browseSource(..., { refresh: true })`): the 60 s
131
+ * window exists to shield the anonymous quota, and a forced re-read is the one caller that means
132
+ * "that window is stale, ask now". It is narrowed to one source on purpose — refreshing GitHub must
133
+ * not discard the npm or pi.dev window another tab just warmed.
134
+ */
135
+ export declare function evictBrowseCache(sourceId: string): void;
136
+ export declare function browseGitHub(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
137
+ /** The empty-query expression one harness opens on (exported so a test can pin the mapping). */
138
+ export declare function npmDefaultQuery(harness: string): string;
139
+ /** The empty-query expression one (kind, harness) pair opens on (exported so a test can pin it). */
140
+ export declare function npmDefaultQueryFor(kind: HarnessKind | undefined, harness: string): string;
141
+ export declare function browseNpm(query: string, limit?: number, defaultQuery?: string, page?: number, sort?: string, installKind?: 'mcp' | 'extension'): Promise<BrowseResult>;
142
+ /**
143
+ * Browse the community catalog. The WHOLE registry is cached (not just the answered slice), so one
144
+ * upstream read serves every keystroke — the same 60 s window the other sources share.
145
+ *
146
+ * A row's key stays `awesome-opencode:<productId>`: the entry names no package. The INSTALL adapter
147
+ * (`sources/awesome-opencode.ts`) resolves a package name on demand and verifies it, rather than the
148
+ * market inventing one here for 136 rows on every keystroke.
149
+ */
150
+ export declare function browseAwesomeOpencode(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
151
+ /**
152
+ * Curated OpenCode ecosystem snapshot (ADR-0015 §D6) — disk-only, so it never answers `unavailable`.
153
+ *
154
+ * Filtering is a substring match over name and description: 31 rows do not justify a ranking model,
155
+ * and an operator typing `pty` or `notif` gets the row they mean either way.
156
+ */
157
+ export declare function browseOpenCodeEcosystem(query: string, limit?: number, page?: number, sort?: string): BrowseResult;
158
+ /**
159
+ * Browse the opencode.cafe catalog. Only `type: 'plugin'` rows are extensions; the catalog's other
160
+ * types (mcp-server, slash-command, hook, theme, web-view, tool) are a different artifact kind and
161
+ * this market cannot install them. The market therefore answers FEWER rows than the site's entry
162
+ * count, and says so: a silent 40-of-54 reads as data loss.
163
+ */
164
+ export declare function browseOpencodeCafe(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
165
+ /**
166
+ * Browse the official Pi package catalog (pi.dev/packages); empty query = its top-downloads page.
167
+ *
168
+ * `total` is the SOURCE's own count — the number the catalog prints in its grid header — because this
169
+ * market lists exactly the catalog's rows, so the range and the total describe the same list. `hasMore`
170
+ * still decides the "next" affordance: a source that stops short of its own count (a short last page)
171
+ * must not advertise a successor.
172
+ *
173
+ * Because nothing is filtered, a window maps onto the catalog arithmetically: console rows `offset …
174
+ * offset+size-1` straddle at most TWO catalog pages (size ≤ 50), so even page 200 costs two fetches and
175
+ * the deep walk below is bounded by construction rather than by a cap.
176
+ */
177
+ export declare function browsePiDev(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
178
+ export declare function browseSkillsSh(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
179
+ export declare function browseSmithery(query: string, limit?: number, page?: number): Promise<BrowseResult>;
180
+ export declare function browseClawHub(query: string, limit?: number, page?: number, sort?: string): Promise<BrowseResult>;
181
+ /**
182
+ * Browse the official MCP registry. Empty query = the registry's own list order (it publishes no
183
+ * ranking parameter and no total, so the console shows the page number without inventing a count).
184
+ *
185
+ * A page past the registry's end answers EMPTY with no successor: a short last page must not
186
+ * advertise a next one, and the console's "empty" is the honest answer there.
187
+ */
188
+ export declare function browseMcpOfficial(query: string, limit?: number, page?: number): Promise<BrowseResult>;
189
+ /** Route a browse request to the adapter that can serve it; unknown/unavailable sources stay honest.
190
+ * `harness` only selects a source's own empty-query default (a pi page opens on pi packages) —
191
+ * it never narrows what a source may return, and it is never a target claim. `page` is 1-based.
192
+ * `sort` is validated against the source's declared `sorts`: an order the upstream cannot serve
193
+ * falls back to the source's own first (default) order instead of being forwarded as a guess.
194
+ * `refresh` is the operator's explicit "ask again": it drops THIS source's cached pages first, so a
195
+ * still-warm 60 s window cannot answer a request that means to be new. */
196
+ export declare function browseSource(source: HarnessSourceView, query: string, limit: number, opts?: {
197
+ harness?: string;
198
+ page?: number;
199
+ sort?: string;
200
+ refresh?: boolean;
201
+ kind?: HarnessKind;
202
+ }): Promise<BrowseResult>;