@oharness/engine 0.11.0 → 0.14.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 (81) hide show
  1. package/dist/agent/agent.d.ts +3 -0
  2. package/dist/agent/agent.js +32 -12
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/agent/background-usage.d.ts +34 -0
  5. package/dist/agent/background-usage.js +53 -0
  6. package/dist/agent/background-usage.js.map +1 -0
  7. package/dist/agent/background.d.ts +2 -0
  8. package/dist/agent/background.js +11 -0
  9. package/dist/agent/background.js.map +1 -1
  10. package/dist/agent/memory-backup.d.ts +1 -1
  11. package/dist/agent/memory-backup.js +1 -1
  12. package/dist/agent/memory-backup.js.map +1 -1
  13. package/dist/agent/memory-digest.d.ts +107 -0
  14. package/dist/agent/memory-digest.js +208 -0
  15. package/dist/agent/memory-digest.js.map +1 -0
  16. package/dist/agent/memory-dream.d.ts +106 -0
  17. package/dist/agent/memory-dream.js +237 -0
  18. package/dist/agent/memory-dream.js.map +1 -0
  19. package/dist/agent/memory-ledger.d.ts +154 -0
  20. package/dist/agent/memory-ledger.js +179 -0
  21. package/dist/agent/memory-ledger.js.map +1 -0
  22. package/dist/agent/memory-provider.d.ts +12 -0
  23. package/dist/agent/memory-recall.d.ts +2 -0
  24. package/dist/agent/memory-recall.js +5 -2
  25. package/dist/agent/memory-recall.js.map +1 -1
  26. package/dist/agent/memory-usage.d.ts +20 -0
  27. package/dist/agent/memory-usage.js +16 -1
  28. package/dist/agent/memory-usage.js.map +1 -1
  29. package/dist/agent/memory.d.ts +3 -0
  30. package/dist/agent/memory.js +24 -4
  31. package/dist/agent/memory.js.map +1 -1
  32. package/dist/agent/skills.d.ts +16 -3
  33. package/dist/agent/skills.js +36 -2
  34. package/dist/agent/skills.js.map +1 -1
  35. package/dist/agent/store.d.ts +7 -0
  36. package/dist/agent/store.js +14 -1
  37. package/dist/agent/store.js.map +1 -1
  38. package/dist/agent/subagent.d.ts +15 -2
  39. package/dist/agent/subagent.js +70 -16
  40. package/dist/agent/subagent.js.map +1 -1
  41. package/dist/config-files.d.ts +6 -1
  42. package/dist/config-files.js +7 -2
  43. package/dist/config-files.js.map +1 -1
  44. package/dist/config.d.ts +9 -0
  45. package/dist/config.js +2 -0
  46. package/dist/config.js.map +1 -1
  47. package/dist/foreign.d.ts +81 -0
  48. package/dist/foreign.js +198 -0
  49. package/dist/foreign.js.map +1 -0
  50. package/dist/harness.d.ts +47 -0
  51. package/dist/harness.js +186 -13
  52. package/dist/harness.js.map +1 -1
  53. package/dist/mcp/registry.d.ts +2 -0
  54. package/dist/mcp/registry.js +1 -0
  55. package/dist/mcp/registry.js.map +1 -1
  56. package/dist/mcp/registry.json +394 -1
  57. package/dist/paths.d.ts +19 -0
  58. package/dist/paths.js +38 -0
  59. package/dist/paths.js.map +1 -1
  60. package/dist/plugin-market.d.ts +57 -0
  61. package/dist/plugin-market.js +229 -0
  62. package/dist/plugin-market.js.map +1 -0
  63. package/dist/plugin-market.json +1246 -0
  64. package/dist/plugins.d.ts +49 -2
  65. package/dist/plugins.js +252 -10
  66. package/dist/plugins.js.map +1 -1
  67. package/dist/runtime-plugins/builtin/dreaming-coordinator.d.ts +244 -0
  68. package/dist/runtime-plugins/builtin/dreaming-coordinator.js +548 -0
  69. package/dist/runtime-plugins/builtin/dreaming-coordinator.js.map +1 -0
  70. package/dist/runtime-plugins/builtin/dreaming.d.ts +30 -0
  71. package/dist/runtime-plugins/builtin/dreaming.js +231 -0
  72. package/dist/runtime-plugins/builtin/dreaming.js.map +1 -0
  73. package/dist/runtime-plugins/builtin/memory.d.ts +89 -2
  74. package/dist/runtime-plugins/builtin/memory.js +186 -5
  75. package/dist/runtime-plugins/builtin/memory.js.map +1 -1
  76. package/dist/runtime-plugins/host.js +2 -0
  77. package/dist/runtime-plugins/host.js.map +1 -1
  78. package/dist/util/toml.d.ts +22 -0
  79. package/dist/util/toml.js +305 -0
  80. package/dist/util/toml.js.map +1 -0
  81. package/package.json +2 -2
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The plugins on offer, and the one way they arrive.
3
+ *
4
+ * The list is ours: picked out of the plugins vendors publish for Claude Code,
5
+ * kept to the ones whose skills, agents or servers this harness can use, and
6
+ * each pinned to the commit that was read when it was picked. Nothing here
7
+ * follows a branch, so what installs is what was looked at.
8
+ *
9
+ * Installing is a download of the parts of that commit this harness reads,
10
+ * from GitHub, into the user's plugin directory with a receipt beside it. The receipt is what makes
11
+ * the directory ours to remove later, and what tells discovery not to adopt
12
+ * the plugin's hooks — see `plugins.ts`.
13
+ */
14
+ export interface MarketPlugin {
15
+ id: string;
16
+ label: string;
17
+ publisher: string;
18
+ category: string;
19
+ description: string;
20
+ /** The vendor's site, from which the menu resolves an icon. */
21
+ siteUrl?: string;
22
+ homepage?: string;
23
+ source: {
24
+ repo: string;
25
+ ref: string;
26
+ path?: string;
27
+ };
28
+ /** What the plugin was seen to contain when it was picked, for the confirm dialog. */
29
+ provides: {
30
+ skills?: number;
31
+ agents?: number;
32
+ servers?: string[];
33
+ hooks?: boolean;
34
+ };
35
+ }
36
+ /** A user's own additions, layered over the bundled list like `connectors.json`. */
37
+ export declare function userMarketPath(): string;
38
+ /** Where installed plugins go: the user layer `discoverPlugins` already reads. */
39
+ export declare function marketInstallRoot(): string;
40
+ /** Every plugin on offer, bundled first and the user's own over the top. */
41
+ export declare function marketPlugins(): Promise<MarketPlugin[]>;
42
+ export interface InstallOptions {
43
+ fetch?: typeof fetch;
44
+ signal?: AbortSignal;
45
+ }
46
+ /**
47
+ * Download one plugin and put it where discovery will find it.
48
+ *
49
+ * Fetched into a scratch directory and copied into place only once it is all
50
+ * there, so a failed or interrupted install leaves nothing behind
51
+ * that the next launch would half-load. A directory of the same name that the
52
+ * marketplace did not create is refused rather than replaced: it is somebody's
53
+ * own plugin, and an install is not the moment to lose it.
54
+ */
55
+ export declare function installMarketPlugin(entry: MarketPlugin, opts?: InstallOptions): Promise<string>;
56
+ /** Remove a plugin the marketplace installed. Anything else is left alone. */
57
+ export declare function removeMarketPlugin(id: string): Promise<boolean>;
@@ -0,0 +1,229 @@
1
+ import { chmod, cp, mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { userPath } from "./paths.js";
6
+ import { MARKET_RECEIPT } from "./plugins.js";
7
+ import { parseJson } from "./util/json.js";
8
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
9
+ /** A user's own additions, layered over the bundled list like `connectors.json`. */
10
+ export function userMarketPath() {
11
+ return process.env["OHARNESS_PLUGIN_MARKET"] ?? userPath("plugin-market.json");
12
+ }
13
+ /** Where installed plugins go: the user layer `discoverPlugins` already reads. */
14
+ export function marketInstallRoot() {
15
+ return process.env["OHARNESS_PLUGIN_DIR"] ?? userPath("plugins");
16
+ }
17
+ /** Every plugin on offer, bundled first and the user's own over the top. */
18
+ export async function marketPlugins() {
19
+ const byId = new Map();
20
+ for (const source of [path.join(HERE, "plugin-market.json"), userMarketPath()]) {
21
+ for (const entry of await readMarket(source))
22
+ byId.set(entry.id, entry);
23
+ }
24
+ return [...byId.values()];
25
+ }
26
+ /** A plugin id and the directory it installs into. Ids are folder names. */
27
+ const ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
28
+ const REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
29
+ const COMMIT = /^[0-9a-f]{40}$/;
30
+ /** No plugin on the list is near these; a download past them is not a plugin. */
31
+ const MAX_BYTES = 80 * 1024 * 1024;
32
+ const MAX_FILES = 3000;
33
+ /**
34
+ * Download one plugin and put it where discovery will find it.
35
+ *
36
+ * Fetched into a scratch directory and copied into place only once it is all
37
+ * there, so a failed or interrupted install leaves nothing behind
38
+ * that the next launch would half-load. A directory of the same name that the
39
+ * marketplace did not create is refused rather than replaced: it is somebody's
40
+ * own plugin, and an install is not the moment to lose it.
41
+ */
42
+ export async function installMarketPlugin(entry, opts = {}) {
43
+ const { repo, ref, path: sub = "" } = entry.source;
44
+ if (!ID.test(entry.id))
45
+ throw new Error(`"${entry.id}" is not a plugin id`);
46
+ if (!REPO.test(repo) || !COMMIT.test(ref))
47
+ throw new Error(`${entry.id} has no pinned source`);
48
+ if (sub.split(/[\\/]/).includes("..") || path.isAbsolute(sub))
49
+ throw new Error(`${entry.id} has a bad source path`);
50
+ const target = path.join(marketInstallRoot(), entry.id);
51
+ if ((await exists(target)) && !(await exists(path.join(target, MARKET_RECEIPT)))) {
52
+ throw new Error(`a plugin named ${entry.id} is already in ${marketInstallRoot()}; remove it first`);
53
+ }
54
+ const scratch = await mkdtemp(path.join(tmpdir(), "oh-plugin-"));
55
+ try {
56
+ const get = (url) => (opts.fetch ?? fetch)(url, { signal: opts.signal ?? AbortSignal.timeout(180_000), redirect: "follow" });
57
+ const root = path.join(scratch, "plugin");
58
+ await downloadPlugin(entry.id, repo, ref, sub, root, get);
59
+ // A plugin with skills but no manifest is still a plugin; discovery needs
60
+ // the manifest to recognise the directory, so one is written.
61
+ const manifest = path.join(root, ".claude-plugin", "plugin.json");
62
+ if (!(await exists(manifest))) {
63
+ await mkdir(path.dirname(manifest), { recursive: true });
64
+ await writeFile(manifest, JSON.stringify({ name: entry.id, description: entry.description }, null, 2));
65
+ }
66
+ const receipt = {
67
+ id: entry.id,
68
+ repo,
69
+ ref,
70
+ ...(sub ? { path: sub } : {}),
71
+ installedAt: new Date().toISOString(),
72
+ };
73
+ await writeFile(path.join(root, MARKET_RECEIPT), JSON.stringify(receipt, null, 2));
74
+ await rm(target, { recursive: true, force: true });
75
+ await mkdir(marketInstallRoot(), { recursive: true });
76
+ await cp(root, target, { recursive: true, verbatimSymlinks: true });
77
+ return target;
78
+ }
79
+ finally {
80
+ await rm(scratch, { recursive: true, force: true });
81
+ }
82
+ }
83
+ /** Remove a plugin the marketplace installed. Anything else is left alone. */
84
+ export async function removeMarketPlugin(id) {
85
+ if (!ID.test(id))
86
+ return false;
87
+ const target = path.join(marketInstallRoot(), id);
88
+ if (!(await exists(path.join(target, MARKET_RECEIPT))))
89
+ return false;
90
+ await rm(target, { recursive: true, force: true });
91
+ return true;
92
+ }
93
+ /**
94
+ * The parts of a plugin this harness reads, at one commit, file by file.
95
+ *
96
+ * Not the repository: several plugins on the list live in a product's own
97
+ * monorepo, or in a folder of one that holds hundreds of other plugins, and
98
+ * downloading all of that to keep a few dozen markdown files was a minute-long
99
+ * install that sometimes did not finish. What is fetched is the manifest
100
+ * folder, `skills/`, `agents/` and the files at the plugin's top level, where
101
+ * its server declarations live. Hooks and scripts stay behind, because
102
+ * discovery does not run a marketplace plugin's hooks anyway.
103
+ *
104
+ * The listing is one API call — `<sha>:<path>` names the folder directly — and
105
+ * two or three more only for a repository too large to list in one. Files come
106
+ * from the raw host, which does not count against the API's hourly limit.
107
+ */
108
+ async function downloadPlugin(id, repo, ref, sub, into, get) {
109
+ const list = async (treeish, recursive) => {
110
+ const response = await get(`https://api.github.com/repos/${repo}/git/trees/${treeish}${recursive ? "?recursive=1" : ""}`);
111
+ if (response.status === 404)
112
+ throw new Error(`${id} has no ${sub || "plugin"} at ${ref.slice(0, 7)}`);
113
+ if (response.status === 403 || response.status === 429) {
114
+ throw new Error(`GitHub is limiting requests from this network; try ${id} again in a while`);
115
+ }
116
+ if (!response.ok)
117
+ throw new Error(`download failed (${response.status}) for ${id}`);
118
+ const body = (await response.json());
119
+ return { ...(body.truncated ? { truncated: true } : {}), tree: body.tree ?? [] };
120
+ };
121
+ const top = `${ref}${sub ? `:${encodeURI(sub)}` : ""}`;
122
+ let files;
123
+ const whole = await list(top, true);
124
+ if (!whole.truncated) {
125
+ files = whole.tree.filter((one) => wanted(one.path));
126
+ }
127
+ else {
128
+ // Too big to list at once: the top level, then each wanted folder by its
129
+ // own tree id.
130
+ const shallow = await list(top, false);
131
+ files = shallow.tree.filter((one) => one.type === "blob");
132
+ for (const folder of shallow.tree.filter((one) => one.type === "tree" && KEEP.has(one.path))) {
133
+ const inner = await list(folder.sha, true);
134
+ if (inner.truncated)
135
+ throw new Error(`${id} is too large to install`);
136
+ files.push(...inner.tree.map((one) => ({ ...one, path: `${folder.path}/${one.path}` })));
137
+ }
138
+ }
139
+ const blobs = files.filter((one) => one.type === "blob" && one.mode !== "120000");
140
+ if (!blobs.length)
141
+ throw new Error(`${id} has nothing to install at ${ref.slice(0, 7)}`);
142
+ if (blobs.length > MAX_FILES || blobs.reduce((sum, one) => sum + (one.size ?? 0), 0) > MAX_BYTES) {
143
+ throw new Error(`${id} is too large to install`);
144
+ }
145
+ await mkdir(into, { recursive: true });
146
+ const queue = [...blobs];
147
+ const drain = async () => {
148
+ for (let blob = queue.shift(); blob; blob = queue.shift()) {
149
+ if (blob.path.split("/").includes("..") || path.isAbsolute(blob.path))
150
+ throw new Error(`${id} has a bad file path`);
151
+ const where = sub ? `${sub}/${blob.path}` : blob.path;
152
+ const response = await get(`https://raw.githubusercontent.com/${repo}/${ref}/${encodeURI(where)}`);
153
+ if (!response.ok)
154
+ throw new Error(`download failed (${response.status}) for ${id}: ${blob.path}`);
155
+ const file = path.join(into, blob.path);
156
+ await mkdir(path.dirname(file), { recursive: true });
157
+ await writeFile(file, Buffer.from(await response.arrayBuffer()));
158
+ if (blob.mode === "100755")
159
+ await chmod(file, 0o755);
160
+ }
161
+ };
162
+ const worker = async () => {
163
+ try {
164
+ await drain();
165
+ }
166
+ catch (err) {
167
+ // The others stop too, rather than writing into a directory that is
168
+ // about to be cleaned up.
169
+ queue.length = 0;
170
+ throw err;
171
+ }
172
+ };
173
+ // A few at a time: fast enough for a folder of skills, polite to the host.
174
+ await Promise.all(Array.from({ length: 8 }, worker));
175
+ }
176
+ /** The folders of a plugin this harness reads. */
177
+ const KEEP = new Set([".claude-plugin", "skills", "agents"]);
178
+ /** Whether a path in the plugin's tree is one this harness reads. */
179
+ function wanted(file) {
180
+ const [first, ...rest] = file.split("/");
181
+ return rest.length === 0 || KEEP.has(first);
182
+ }
183
+ async function readMarket(file) {
184
+ let raw;
185
+ try {
186
+ raw = await readFile(file, "utf8");
187
+ }
188
+ catch {
189
+ return [];
190
+ }
191
+ const parsed = parseJson(raw);
192
+ if (!parsed.ok || !parsed.value.plugins || typeof parsed.value.plugins !== "object")
193
+ return [];
194
+ const out = [];
195
+ for (const [id, value] of Object.entries(parsed.value.plugins)) {
196
+ const entry = value;
197
+ const source = entry?.source;
198
+ // An entry that could never install is a typo; offering it would put a
199
+ // button in the menu that can only fail.
200
+ if (!ID.test(id) || !source || typeof source.repo !== "string" || typeof source.ref !== "string")
201
+ continue;
202
+ out.push({
203
+ id,
204
+ label: typeof entry.label === "string" ? entry.label : id,
205
+ publisher: typeof entry.publisher === "string" ? entry.publisher : "",
206
+ category: typeof entry.category === "string" ? entry.category : "other",
207
+ description: typeof entry.description === "string" ? entry.description : "",
208
+ ...(typeof entry.siteUrl === "string" ? { siteUrl: entry.siteUrl } : {}),
209
+ ...(typeof entry.homepage === "string" ? { homepage: entry.homepage } : {}),
210
+ source: {
211
+ repo: source.repo,
212
+ ref: source.ref,
213
+ ...(typeof source.path === "string" && source.path ? { path: source.path } : {}),
214
+ },
215
+ provides: entry.provides && typeof entry.provides === "object" ? entry.provides : {},
216
+ });
217
+ }
218
+ return out;
219
+ }
220
+ async function exists(file) {
221
+ try {
222
+ await stat(file);
223
+ return true;
224
+ }
225
+ catch {
226
+ return false;
227
+ }
228
+ }
229
+ //# sourceMappingURL=plugin-market.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-market.js","sourceRoot":"","sources":["../src/plugin-market.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,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