@nodeskai/genehub-sdk 0.1.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.
@@ -0,0 +1,187 @@
1
+ import { GeneAdapter, GeneManifest, InstallOptions, InstallResult, UninstallResult, UninstallOptions, InstalledGene, GeneListParams, PaginatedData, Gene, GeneVersion, Genome, ResolvedGene } from '@nodeskai/genehub-types';
2
+
3
+ declare abstract class BaseAdapter implements GeneAdapter {
4
+ abstract readonly product: string;
5
+ abstract detect(): Promise<boolean>;
6
+ install(manifest: GeneManifest, options?: InstallOptions): Promise<InstallResult>;
7
+ protected abstract doInstall(manifest: GeneManifest, options?: InstallOptions): Promise<InstallResult>;
8
+ protected onPostInstall(_manifest: GeneManifest, _result: InstallResult): Promise<void>;
9
+ protected onPostUninstall(_slug: string, _result: UninstallResult): Promise<void>;
10
+ uninstall(slug: string, options?: UninstallOptions): Promise<UninstallResult>;
11
+ protected abstract doUninstall(slug: string, options?: UninstallOptions): Promise<UninstallResult>;
12
+ abstract list(): Promise<InstalledGene[]>;
13
+ abstract isInstalled(slug: string): Promise<boolean>;
14
+ abstract getInstalledVersion(slug: string): Promise<string | null>;
15
+ protected generateSkillContent(manifest: GeneManifest, metadataNamespace: string): string;
16
+ protected parseSkillVersion(content: string): string | null;
17
+ }
18
+
19
+ declare class GenericAdapter extends BaseAdapter {
20
+ readonly product = "generic";
21
+ private genesDir;
22
+ constructor(options?: {
23
+ genesDir?: string;
24
+ });
25
+ detect(): Promise<boolean>;
26
+ protected doInstall(manifest: GeneManifest, options?: InstallOptions): Promise<InstallResult>;
27
+ protected doUninstall(slug: string, _options?: UninstallOptions): Promise<UninstallResult>;
28
+ list(): Promise<InstalledGene[]>;
29
+ isInstalled(slug: string): Promise<boolean>;
30
+ getInstalledVersion(slug: string): Promise<string | null>;
31
+ }
32
+
33
+ declare function detectAdapter(): Promise<GeneAdapter>;
34
+ declare function getAdapter(product: string): GeneAdapter;
35
+
36
+ declare class NanobotAdapter extends BaseAdapter {
37
+ readonly product = "nanobot";
38
+ private workspace;
39
+ constructor(options?: {
40
+ workspace?: string;
41
+ });
42
+ private get skillsDir();
43
+ detect(): Promise<boolean>;
44
+ protected doInstall(manifest: GeneManifest, options?: InstallOptions): Promise<InstallResult>;
45
+ protected onPostInstall(manifest: GeneManifest, _result: InstallResult): Promise<void>;
46
+ protected doUninstall(slug: string, _options?: UninstallOptions): Promise<UninstallResult>;
47
+ protected onPostUninstall(slug: string, _result: UninstallResult): Promise<void>;
48
+ list(): Promise<InstalledGene[]>;
49
+ isInstalled(slug: string): Promise<boolean>;
50
+ getInstalledVersion(slug: string): Promise<string | null>;
51
+ private writeMemoryEntry;
52
+ private buildNanobotSkillContent;
53
+ private mergeNanobotMcpConfig;
54
+ }
55
+
56
+ declare class OpenClawAdapter extends BaseAdapter {
57
+ readonly product = "openclaw";
58
+ private skillsDir;
59
+ private configPath;
60
+ private configDir;
61
+ private workspaceDir;
62
+ constructor(options?: {
63
+ skillsDir?: string;
64
+ configPath?: string;
65
+ workspaceDir?: string;
66
+ configDir?: string;
67
+ });
68
+ detect(): Promise<boolean>;
69
+ protected doInstall(manifest: GeneManifest, options?: InstallOptions): Promise<InstallResult>;
70
+ protected onPostInstall(manifest: GeneManifest, _result: InstallResult): Promise<void>;
71
+ protected doUninstall(slug: string, _options?: UninstallOptions): Promise<UninstallResult>;
72
+ protected onPostUninstall(slug: string, _result: UninstallResult): Promise<void>;
73
+ list(): Promise<InstalledGene[]>;
74
+ isInstalled(slug: string): Promise<boolean>;
75
+ getInstalledVersion(slug: string): Promise<string | null>;
76
+ private updateAgentsMd;
77
+ private writeMemoryEntry;
78
+ private mergeOpenClawConfig;
79
+ private mergeMcpServers;
80
+ notifySkillChange(geneName: string, action: 'installed' | 'updated' | 'uninstalled'): Promise<void>;
81
+ /**
82
+ * Clear cached skillsSnapshot from all OpenClaw sessions.
83
+ * Without this, OpenClaw keeps using the stale skill list even after restart.
84
+ */
85
+ private invalidateSkillSnapshots;
86
+ /**
87
+ * Inject evolution notification into all active session JSONL files.
88
+ *
89
+ * Old conversation history may contain stale skill listings from the agent.
90
+ * The LLM repeats its previous answer instead of re-checking the system prompt.
91
+ * By appending a user+assistant message pair about the evolution, we override
92
+ * the stale context. Also resets systemSent to force system prompt rebuild.
93
+ */
94
+ private injectEvolutionNotification;
95
+ }
96
+
97
+ type GeneHubClientOptions = {
98
+ registryUrl: string;
99
+ token?: string;
100
+ };
101
+ declare class GeneHubClient {
102
+ private baseUrl;
103
+ private token?;
104
+ constructor(options: GeneHubClientOptions);
105
+ private request;
106
+ searchGenes(params?: GeneListParams): Promise<PaginatedData<Gene>>;
107
+ getGene(slug: string): Promise<Gene>;
108
+ getManifest(slug: string, version?: string): Promise<GeneManifest>;
109
+ getVersions(slug: string): Promise<GeneVersion[]>;
110
+ getVersion(slug: string, version: string): Promise<GeneVersion>;
111
+ getGenome(slug: string): Promise<Genome>;
112
+ publishGene(manifest: GeneManifest): Promise<Gene>;
113
+ publishVersion(slug: string, manifest: GeneManifest, changelog?: string): Promise<Gene>;
114
+ resolve(slug: string, version?: string, product?: string): Promise<{
115
+ plan: ResolvedGene[];
116
+ warnings: string[];
117
+ }>;
118
+ reportInstall(slug: string): Promise<void>;
119
+ reportEffectiveness(slug: string, report: {
120
+ metric_type: string;
121
+ value: number;
122
+ context?: string;
123
+ }): Promise<void>;
124
+ }
125
+
126
+ type LearningMode = 'learn' | 'create' | 'forget';
127
+ type LearningScenario = {
128
+ title: string;
129
+ context: string;
130
+ expected_focus: string;
131
+ };
132
+ type LearningTask = {
133
+ mode: LearningMode;
134
+ task_id: string;
135
+ gene_slug: string;
136
+ gene_name: string;
137
+ gene_version: string;
138
+ gene_content: string;
139
+ gene_meta: {
140
+ name: string;
141
+ description: string;
142
+ category: string;
143
+ short_description: string;
144
+ };
145
+ learning?: {
146
+ objectives?: string[];
147
+ scenarios?: LearningScenario[];
148
+ force_deep_learn?: boolean;
149
+ };
150
+ callback_path: string;
151
+ created_at: string;
152
+ };
153
+ type LearningDecision = 'direct_install' | 'learned' | 'failed' | 'created' | 'forgotten' | 'simplified' | 'forget_failed';
154
+ type LearningResult = {
155
+ task_id: string;
156
+ gene_slug: string;
157
+ mode: LearningMode;
158
+ decision: LearningDecision;
159
+ content?: string;
160
+ self_eval?: number;
161
+ reason?: string;
162
+ completed_at: string;
163
+ };
164
+
165
+ type LearningEngineOptions = {
166
+ workspaceDir: string;
167
+ adapter?: GeneAdapter;
168
+ };
169
+ declare class LearningEngine {
170
+ private workspaceDir;
171
+ private adapter?;
172
+ constructor(options: LearningEngineOptions);
173
+ private get tasksDir();
174
+ private get resultsDir();
175
+ ensureMetaGeneInstalled(): Promise<boolean>;
176
+ private injectBootInstruction;
177
+ createLearningTask(manifest: GeneManifest): Promise<LearningTask>;
178
+ createForgetTask(slug: string, name: string, skillContent: string): Promise<void>;
179
+ checkResult(slug: string): Promise<LearningResult | null>;
180
+ listPendingTasks(): Promise<string[]>;
181
+ listCompletedResults(): Promise<LearningResult[]>;
182
+ applyResult(slug: string, skillsDir: string): Promise<boolean>;
183
+ cleanupTask(slug: string): Promise<void>;
184
+ private parseResult;
185
+ }
186
+
187
+ export { GeneHubClient, GenericAdapter, LearningEngine, type LearningEngineOptions, type LearningResult, type LearningTask, NanobotAdapter, OpenClawAdapter, detectAdapter, getAdapter };