@hydraharness/harness-plugin-runtime 0.1.1-rc.5

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.
@@ -0,0 +1,13 @@
1
+ //#region lib/types/invariant.js
2
+ /** Package-owned invariant companion. @module @hydraharness/harness-plugin-runtime/invariant */
3
+ const PACKAGE_NAME = "@hydraharness/harness-plugin-runtime";
4
+ /** Cordis companion plugin name. */
5
+ const name = "plugin-runtime-invariant";
6
+ /** Service required before the companion can reserve package ownership. */
7
+ const inject = ["invariants"];
8
+ /** No runtime invariant: runtime lifecycle observations are covered by the package's focused tests. */
9
+ const install = () => {};
10
+ /** Register the package ownership companion. */
11
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
12
+ //#endregion
13
+ export { apply, inject, name };
@@ -0,0 +1,310 @@
1
+ /** Shared, immutable runtime for imported OpenAI/Codex and Claude plugin bundles. */
2
+ import { Service, type Context } from '@hydraharness/cordis';
3
+ import { type Config as McpClientConfig } from '@hydraharness/harness-mcp-client';
4
+ import { type SkillDocument } from '@hydraharness/harness-skill';
5
+ import type { ImportedPluginAgentMetadata, ImportedPluginEntry, ImportedPluginSnapshot, ImportedPluginSource, PluginImportSource, PluginManifest } from './types.ts';
6
+ export type * from './types.ts';
7
+ declare module '@hydraharness/cordis' {
8
+ interface Context {
9
+ importedPlugins: ImportedPluginRuntime;
10
+ }
11
+ }
12
+ /** Services required by the imported-plugin runtime. */
13
+ export declare const inject: string[];
14
+ /** Runtime configuration for the imported-plugin service. */
15
+ export interface Config {
16
+ /** Override the resolved Hydra home directory. */
17
+ hydraHome?: string;
18
+ }
19
+ interface HookDefinition {
20
+ readonly label: string;
21
+ readonly raw: Record<string, unknown>;
22
+ }
23
+ interface McpDefinition {
24
+ readonly name: string;
25
+ readonly config: McpClientConfig;
26
+ }
27
+ interface LoadedPlugin {
28
+ readonly root: string;
29
+ readonly manifest: PluginManifest;
30
+ readonly skills: readonly LoadedSkill[];
31
+ readonly commands: readonly LoadedCommand[];
32
+ readonly mcp: readonly McpDefinition[];
33
+ readonly hooks: readonly HookDefinition[];
34
+ readonly hookDigest?: string;
35
+ readonly apps?: Readonly<Record<string, unknown>>;
36
+ readonly agentMetadata?: ImportedPluginAgentMetadata;
37
+ }
38
+ interface LoadedSkill {
39
+ readonly rawName: string;
40
+ readonly description: string;
41
+ readonly whenToUse?: string;
42
+ readonly invocation: SkillDocument['invocation'];
43
+ readonly path: string;
44
+ readonly directory: string;
45
+ readonly agentMetadata?: ImportedPluginAgentMetadata;
46
+ readonly openAiModelInvocable: boolean;
47
+ }
48
+ interface LoadedCommand {
49
+ readonly name: string;
50
+ readonly description: string;
51
+ readonly prompt: string;
52
+ readonly inputHint?: string;
53
+ }
54
+ interface StoredMcpState {
55
+ enabled: boolean;
56
+ defaultToolsApprovalMode: 'ask' | 'allow' | 'deny';
57
+ toolApproval: Record<string, 'ask' | 'allow' | 'deny'>;
58
+ }
59
+ interface StoredPlugin {
60
+ name: string;
61
+ source: ImportedPluginSource;
62
+ activeVersion: string;
63
+ versions: Record<string, {
64
+ installedAt: string;
65
+ }>;
66
+ enabled: boolean;
67
+ hookTrustDigest?: string;
68
+ mcp: Record<string, StoredMcpState>;
69
+ }
70
+ /** Plugin root resolver and manifest parser. It never executes plugin files. */
71
+ export declare class PluginManifestLoader {
72
+ /**
73
+ * Validate and discover one bundle without executing it.
74
+ * @param root - Candidate plugin-root directory.
75
+ * @param identity - Source-qualified identity used to namespace MCP servers.
76
+ * @returns Parsed manifest and discovered component definitions.
77
+ */
78
+ load(root: string, identity?: string): Promise<LoadedPlugin>;
79
+ }
80
+ /** Durable registry and immutable bundle store beneath one Hydra home directory. */
81
+ export declare class PluginStore {
82
+ readonly home: string;
83
+ /** Immutable versioned plugin-bundle root. */
84
+ readonly cacheRoot: string;
85
+ /** Persistent writable plugin-data root. */
86
+ readonly dataRoot: string;
87
+ /** Durable source-qualified plugin registry path. */
88
+ readonly registryPath: string;
89
+ private readonly manifests;
90
+ constructor(home?: string);
91
+ /**
92
+ * List every stored entry by source-qualified identity.
93
+ * @returns Every stored entry by source-qualified identity.
94
+ */
95
+ list(): Promise<ReadonlyMap<string, StoredPlugin>>;
96
+ /**
97
+ * Read one stored plugin entry.
98
+ * @param identity - Source-qualified plugin identity.
99
+ * @returns Stored entry, or undefined when absent.
100
+ */
101
+ get(identity: string): Promise<StoredPlugin | undefined>;
102
+ /**
103
+ * Validate, stage, and activate one imported source.
104
+ * @param source - Local, Git, or marketplace source.
105
+ * @returns Source-qualified identity of the activated plugin.
106
+ */
107
+ install(source: PluginImportSource): Promise<string>;
108
+ /**
109
+ * Mutate one durable entry while holding the registry lock.
110
+ * @param identity - Source-qualified plugin identity.
111
+ * @param mutation - In-place mutation applied before atomic persistence.
112
+ * @returns After the registry is persisted.
113
+ */
114
+ update(identity: string, mutation: (entry: StoredPlugin) => void): Promise<void>;
115
+ /**
116
+ * Remove one registry entry and its owned bundle and data directories.
117
+ * @param identity - Source-qualified plugin identity.
118
+ * @returns Removed entry, or undefined when absent.
119
+ */
120
+ remove(identity: string): Promise<StoredPlugin | undefined>;
121
+ /**
122
+ * Resolve the active immutable bundle path.
123
+ * @param entry - Stored plugin entry.
124
+ * @returns Active version directory.
125
+ */
126
+ bundlePath(entry: StoredPlugin): string;
127
+ /**
128
+ * Resolve the persistent writable data path.
129
+ * @param entry - Stored plugin entry.
130
+ * @returns Plugin data directory.
131
+ */
132
+ dataPath(entry: StoredPlugin): string;
133
+ /**
134
+ * Load one active stored bundle.
135
+ * @param entry - Stored plugin entry.
136
+ * @param identity - Source-qualified plugin identity.
137
+ * @returns Parsed active bundle.
138
+ */
139
+ load(entry: StoredPlugin, identity: string): Promise<LoadedPlugin>;
140
+ private readRegistry;
141
+ private writeRegistry;
142
+ private ensureRegistryDirectory;
143
+ }
144
+ /** Lightweight views over the durable records; the runtime owns live components. */
145
+ export declare class PluginRegistry {
146
+ private readonly store;
147
+ constructor(store: PluginStore);
148
+ /**
149
+ * List every stored entry by source-qualified identity.
150
+ * @returns Every stored entry by source-qualified identity.
151
+ */
152
+ list(): Promise<ReadonlyMap<string, StoredPlugin>>;
153
+ /**
154
+ * Read one stored plugin entry.
155
+ * @param identity - Source-qualified plugin identity.
156
+ * @returns Stored entry, or undefined when absent.
157
+ */
158
+ get(identity: string): Promise<StoredPlugin | undefined>;
159
+ }
160
+ /** Explicit names for the runtime's independent trust and component registries. */
161
+ export declare class PluginTrustStore {
162
+ private readonly store;
163
+ constructor(store: PluginStore);
164
+ /**
165
+ * Record trust for one exact hook definition digest.
166
+ * @param identity - Source-qualified plugin identity.
167
+ * @param definitionDigest - Current canonical hook-definition digest.
168
+ * @returns After trust persistence completes.
169
+ */
170
+ trust(identity: string, definitionDigest: string): Promise<void>;
171
+ /**
172
+ * Remove recorded hook trust.
173
+ * @param identity - Source-qualified plugin identity.
174
+ * @returns After trust removal persists.
175
+ */
176
+ untrust(identity: string): Promise<void>;
177
+ }
178
+ /** Public lifecycle facade over the shared imported-plugin runtime. */
179
+ export declare class PluginLifecycleManager {
180
+ private readonly runtime;
181
+ constructor(runtime: ImportedPluginRuntime);
182
+ /**
183
+ * Enable and load one plugin.
184
+ * @param identity - Source-qualified plugin identity.
185
+ * @returns Refreshed installed-plugin projection.
186
+ */
187
+ enable(identity: string): Promise<ImportedPluginSnapshot>;
188
+ /**
189
+ * Disable and unload one plugin.
190
+ * @param identity - Source-qualified plugin identity.
191
+ * @returns Refreshed installed-plugin projection.
192
+ */
193
+ disable(identity: string): Promise<ImportedPluginSnapshot>;
194
+ /**
195
+ * Unload one plugin's live components.
196
+ * @param identity - Source-qualified plugin identity.
197
+ * @returns After owned components quiesce.
198
+ */
199
+ unload(identity: string): Promise<void>;
200
+ }
201
+ /** Shared `@hydraharness/harness-base` service for every imported bundle, not a Web-only facility. */
202
+ export declare class ImportedPluginRuntime extends Service {
203
+ static inject: string[];
204
+ /** Component effects belong to the Host service, independent of a method caller's context. */
205
+ private readonly owner;
206
+ private readonly store;
207
+ /** Read-only facade over durable imported-plugin records. */
208
+ readonly registry: PluginRegistry;
209
+ /** Hook-definition trust record manager. */
210
+ readonly trust: PluginTrustStore;
211
+ /** Enablement and teardown facade. */
212
+ readonly lifecycle: PluginLifecycleManager;
213
+ private readonly live;
214
+ private readonly initialEnabled;
215
+ private readonly startup;
216
+ private mutationTail;
217
+ constructor(ctx: Context, config?: Config);
218
+ protected [Service.init](): Promise<void>;
219
+ /**
220
+ * Return every imported plugin's current source-qualified runtime view.
221
+ * @returns Current installed-plugin projection.
222
+ */
223
+ list(): Promise<ImportedPluginSnapshot>;
224
+ /**
225
+ * Return one installed plugin view.
226
+ * @param identityOrName - Source-qualified identity or an unambiguous plugin name.
227
+ * @returns Current installed-plugin projection.
228
+ */
229
+ info(identityOrName: string): Promise<ImportedPluginEntry>;
230
+ /**
231
+ * Stage one local, Git, or marketplace source.
232
+ * @param source - Source to import.
233
+ * @returns Refreshed installed-plugin projection.
234
+ */
235
+ import(source: PluginImportSource): Promise<ImportedPluginSnapshot>;
236
+ /**
237
+ * Enable and load one plugin.
238
+ * @param identityOrName - Plugin identity or unambiguous name.
239
+ * @returns Refreshed installed-plugin projection.
240
+ */
241
+ enable(identityOrName: string): Promise<ImportedPluginSnapshot>;
242
+ /**
243
+ * Disable and unload one plugin.
244
+ * @param identityOrName - Plugin identity or unambiguous name.
245
+ * @returns Refreshed installed-plugin projection.
246
+ */
247
+ disable(identityOrName: string): Promise<ImportedPluginSnapshot>;
248
+ /**
249
+ * Trust one plugin's current hook definition.
250
+ * @param identityOrName - Plugin identity or unambiguous name.
251
+ * @returns Refreshed installed-plugin projection.
252
+ */
253
+ trustHooks(identityOrName: string): Promise<ImportedPluginSnapshot>;
254
+ /**
255
+ * Revoke one plugin's hook trust.
256
+ * @param identityOrName - Plugin identity or unambiguous name.
257
+ * @returns Refreshed installed-plugin projection.
258
+ */
259
+ untrustHooks(identityOrName: string): Promise<ImportedPluginSnapshot>;
260
+ /**
261
+ * Unload and remove one plugin with its owned store paths.
262
+ * @param identityOrName - Plugin identity or unambiguous name.
263
+ * @returns Refreshed installed-plugin projection.
264
+ */
265
+ remove(identityOrName: string): Promise<ImportedPluginSnapshot>;
266
+ /**
267
+ * Set one plugin MCP server's lifecycle state.
268
+ * @param identityOrName - Owning plugin identity or unambiguous name.
269
+ * @param server - Manifest MCP server name.
270
+ * @param enabled - Desired server state.
271
+ * @returns Refreshed installed-plugin projection.
272
+ */
273
+ setMcpServerEnabled(identityOrName: string, server: string, enabled: boolean): Promise<ImportedPluginSnapshot>;
274
+ /**
275
+ * Set one MCP tool's approval mode.
276
+ * @param identityOrName - Owning plugin identity or unambiguous name.
277
+ * @param server - Manifest MCP server name.
278
+ * @param tool - Raw MCP tool name or host-qualified public tool name.
279
+ * @param approval - Independent per-tool approval mode.
280
+ * @returns Refreshed installed-plugin projection.
281
+ */
282
+ setMcpToolApproval(identityOrName: string, server: string, tool: string, approval: 'ask' | 'allow' | 'deny'): Promise<ImportedPluginSnapshot>;
283
+ /**
284
+ * Unload every live component owned by one plugin.
285
+ * @param identity - Installed plugin identity.
286
+ * @returns After skills, hooks, and MCP fibers quiesce.
287
+ */
288
+ unload(identity: string): Promise<void>;
289
+ private load;
290
+ private reload;
291
+ private registerSkills;
292
+ private registerCommands;
293
+ private startMcp;
294
+ private startHooks;
295
+ private view;
296
+ private resolve;
297
+ private require;
298
+ private enqueue;
299
+ private approveMcpTool;
300
+ private marketplaceInventory;
301
+ private requireMarketplaceInventory;
302
+ private resolveMarketplace;
303
+ private marketplaceCommand;
304
+ private installCommand;
305
+ private command;
306
+ private dispose;
307
+ }
308
+ export declare const name = "plugin-runtime";
309
+ export default ImportedPluginRuntime;
310
+ //# sourceMappingURL=index.d.ts.map