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,83 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { getOcrHomeDir } from '../cli/paths.js';
4
+ import { renameWithRetry } from '../utils/atomic-write.js';
5
+ import { EventRing, EVENT_MESSAGE_MAX_CHARS, nextRingEventId, truncateEventMessage, } from '../utils/event-ring.js';
6
+ const CAP = 500;
7
+ function appliesPath() {
8
+ return path.join(getOcrHomeDir(), 'harness', 'applies.json');
9
+ }
10
+ /** Fail-open durable mirror: bounded array of rows, upsert-by-id, newest-kept trim. */
11
+ class AppliesFileStore {
12
+ rows() {
13
+ try {
14
+ if (!fs.existsSync(appliesPath()))
15
+ return [];
16
+ const parsed = JSON.parse(fs.readFileSync(appliesPath(), 'utf8'));
17
+ return Array.isArray(parsed) ? parsed : [];
18
+ }
19
+ catch {
20
+ return [];
21
+ }
22
+ }
23
+ write(rows) {
24
+ try {
25
+ fs.mkdirSync(path.dirname(appliesPath()), { recursive: true });
26
+ const tmp = `${appliesPath()}.tmp.${process.pid}.${Date.now()}`;
27
+ fs.writeFileSync(tmp, JSON.stringify(rows, null, 2) + '\n', 'utf8');
28
+ renameWithRetry(tmp, appliesPath());
29
+ }
30
+ catch {
31
+ // fail-open — an observability write never breaks the apply path
32
+ }
33
+ }
34
+ upsert(ev) {
35
+ const rows = this.rows().filter((r) => r.id !== ev.id);
36
+ rows.push(ev);
37
+ this.write(rows.slice(-CAP));
38
+ }
39
+ loadRecent(limit) {
40
+ return this.rows().slice(-limit);
41
+ }
42
+ trim(keep) {
43
+ const rows = this.rows();
44
+ if (rows.length > keep)
45
+ this.write(rows.slice(-keep));
46
+ }
47
+ clearAll() {
48
+ this.write([]);
49
+ }
50
+ }
51
+ const ring = new EventRing(new AppliesFileStore());
52
+ /** Append one apply row; returns the row id. Never throws. */
53
+ export function recordApply(input) {
54
+ const now = Date.now();
55
+ const ev = {
56
+ id: nextRingEventId('ha-', now),
57
+ ts: now,
58
+ action: input.action,
59
+ kind: input.kind,
60
+ artifactId: input.artifactId,
61
+ name: input.name,
62
+ hosts: input.hosts.join(','),
63
+ command: input.command ?? '',
64
+ outcome: input.outcome,
65
+ message: truncateEventMessage(input.message, EVENT_MESSAGE_MAX_CHARS),
66
+ };
67
+ try {
68
+ ring.append(ev);
69
+ }
70
+ catch {
71
+ // fail-open
72
+ }
73
+ return ev.id;
74
+ }
75
+ /** Newest-first rows (display order). */
76
+ export function recentApplies(limit = 100) {
77
+ try {
78
+ return ring.rows().reverse().slice(0, limit);
79
+ }
80
+ catch {
81
+ return [];
82
+ }
83
+ }
@@ -0,0 +1,115 @@
1
+ import type { DiscoveredRemoval } from './types.js';
2
+ /**
3
+ * Maintenance writes for harness artifacts (ADR-0015 §D5).
4
+ *
5
+ * The op follows the artifact's LANDING SHAPE, never its provenance — that is the whole design:
6
+ *
7
+ * file tree / loose file → move-to-trash (reversible through the trash)
8
+ * config array entry → drop-entry (`plugin[]`, pi `packages[]`: one string)
9
+ * config object member → drop-server (an MCP server inside `mcp`)
10
+ * package, no declaration → prune-record (nothing of ours to touch)
11
+ *
12
+ * Provenance decides nothing here: a discovered row and a tracked copy of the same package land in
13
+ * the same place and are removed by the same op. What the shape DOES decide is what may be destroyed:
14
+ * a copy whose `path` is the runtime's own CONFIG FILE must never be trashed — moving
15
+ * `opencode.json` to the trash would delete every other server and plugin in it, which is why a
16
+ * config landing is removed member-by-member here instead.
17
+ *
18
+ * A plan may span SEVERAL artifacts, because uninstall is a location-level choice in the console: the
19
+ * operator ticks individual `(host, path)` positions, which usually belong to different artifacts.
20
+ * The whole plan is one transaction — trash snapshot per moved directory, manifest pruning only after
21
+ * every filesystem write succeeded, and a stale plan is refused rather than re-interpreted.
22
+ *
23
+ * Ownership guard for a directory with no manifest entry is ROOT CONTAINMENT: it must sit directly
24
+ * under a known skills root, otherwise a crafted request could delete anything on disk.
25
+ */
26
+ export interface RemoveTarget {
27
+ scope: 'global' | 'project';
28
+ host: string;
29
+ path: string;
30
+ }
31
+ export interface RemoveItem {
32
+ /** `null` = a copy that already existed on this machine (no manifest entry). */
33
+ artifactId: string | null;
34
+ copies: RemoveTarget[];
35
+ /**
36
+ * Present for a discovered row: the runtime's own record, as the discovery scan read it. When set
37
+ * it is authoritative — `copies` is then display-only, because a package's `path` is an identity
38
+ * token and there is no location to reconcile.
39
+ */
40
+ removal?: DiscoveredRemoval;
41
+ }
42
+ export interface PlanAction {
43
+ /**
44
+ * `move-to-trash` (a path we own), `prune-only` (the copy or member is already gone), `prune-record`
45
+ * (package-manager-owned with no declaration file to edit), `drop-entry` (one string inside a JSON
46
+ * array) or `drop-server` (one member of a JSON object, e.g. a server in `mcp`).
47
+ */
48
+ op: 'move-to-trash' | 'prune-only' | 'prune-record' | 'drop-entry' | 'drop-server';
49
+ /** The manifest copy key: a resolved path, or the identity token for an `external` copy. */
50
+ path: string;
51
+ /** The config file a `drop-*` op edits — display + the write target. */
52
+ file?: string;
53
+ /** Container inside `file` (`plugin` / `packages` / `mcp`). */
54
+ container?: string;
55
+ /** The exact member removed: an array element (`drop-entry`) or an object key (`drop-server`). */
56
+ entry?: string;
57
+ host: string;
58
+ artifactId: string | null;
59
+ beforeHash?: string;
60
+ dirty: boolean;
61
+ exists: boolean;
62
+ }
63
+ export interface RemovePlan {
64
+ planId: string;
65
+ action: 'remove';
66
+ artifactIds: string[];
67
+ actions: PlanAction[];
68
+ /**
69
+ * Copies whose `path` is an identity token, not a location (`CopyRecord.external`). Their removal
70
+ * edits the runtime's own declaration when the host catalog names one; otherwise it can only prune
71
+ * this gateway's record, and the plan says so verbatim.
72
+ */
73
+ external: {
74
+ path: string;
75
+ host: string;
76
+ }[];
77
+ blocked: {
78
+ path: string;
79
+ code: 'foreign' | 'unknown-copy' | 'not-found' | 'unreadable';
80
+ message: string;
81
+ }[];
82
+ warnings: {
83
+ code: 'dirty-copy';
84
+ message: string;
85
+ path: string;
86
+ }[];
87
+ createdAt: number;
88
+ }
89
+ /** Build a dry-run removal plan over one or more artifacts. Writes nothing. */
90
+ export declare function planRemove(items: RemoveItem[]): RemovePlan | {
91
+ error: string;
92
+ };
93
+ export type ApplyResult = {
94
+ ok: true;
95
+ removed: string[];
96
+ trashDir: string | null;
97
+ prunedArtifacts: string[];
98
+ /** Plain-language note when the plan edited a runtime's own record instead of moving a path. */
99
+ message?: string;
100
+ } | {
101
+ ok: false;
102
+ code: 'plan_unknown' | 'plan_stale' | 'dirty_copy' | 'apply_failed';
103
+ message: string;
104
+ };
105
+ /**
106
+ * Execute a removal plan. The manifest is written only after every filesystem write succeeded, so a
107
+ * failure leaves the artifacts recorded rather than orphaned.
108
+ *
109
+ * `drop-entry` / `drop-server` edit a runtime's config file through `createBackup` + `safeWriteJson`
110
+ * — the same discipline that wrote the member — and never release the path's claim: the file still
111
+ * exists and commonly holds other artifacts' members.
112
+ */
113
+ export declare function applyRemove(planId: string, opts?: {
114
+ discardLocalEdits?: boolean;
115
+ }): ApplyResult;