@babyclaw/gateway 0.0.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,228 @@
1
+ import { z } from 'zod';
2
+ import { LanguageModel } from 'ai';
3
+ import pino from 'pino';
4
+ export { Logger } from 'pino';
5
+
6
+ declare const babyclawConfigSchema: z.ZodObject<{
7
+ version: z.ZodLiteral<1>;
8
+ telegram: z.ZodOptional<z.ZodObject<{
9
+ botToken: z.ZodString;
10
+ }, z.core.$strict>>;
11
+ channels: z.ZodDefault<z.ZodObject<{
12
+ telegram: z.ZodOptional<z.ZodObject<{
13
+ botToken: z.ZodString;
14
+ }, z.core.$strict>>;
15
+ }, z.core.$strict>>;
16
+ ai: z.ZodObject<{
17
+ providers: z.ZodRecord<z.ZodString, z.ZodObject<{
18
+ apiKey: z.ZodString;
19
+ baseUrl: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>>;
21
+ models: z.ZodObject<{
22
+ chat: z.ZodString;
23
+ vision: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strict>;
25
+ aliases: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
26
+ }, z.core.$strict>;
27
+ scheduler: z.ZodDefault<z.ZodObject<{
28
+ timezone: z.ZodDefault<z.ZodString>;
29
+ }, z.core.$strict>>;
30
+ workspace: z.ZodDefault<z.ZodObject<{
31
+ root: z.ZodDefault<z.ZodString>;
32
+ }, z.core.$strict>>;
33
+ session: z.ZodDefault<z.ZodObject<{
34
+ maxMessagesPerSession: z.ZodDefault<z.ZodNumber>;
35
+ historyLimit: z.ZodDefault<z.ZodNumber>;
36
+ replyChainMode: z.ZodDefault<z.ZodEnum<{
37
+ default: "default";
38
+ "reply-chain": "reply-chain";
39
+ }>>;
40
+ titleGeneration: z.ZodDefault<z.ZodObject<{
41
+ model: z.ZodOptional<z.ZodString>;
42
+ prompt: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strict>>;
44
+ }, z.core.$strict>>;
45
+ tools: z.ZodDefault<z.ZodObject<{
46
+ enableGenericTools: z.ZodDefault<z.ZodBoolean>;
47
+ shell: z.ZodDefault<z.ZodObject<{
48
+ mode: z.ZodDefault<z.ZodEnum<{
49
+ allowlist: "allowlist";
50
+ "full-access": "full-access";
51
+ }>>;
52
+ allowedCommands: z.ZodDefault<z.ZodArray<z.ZodString>>;
53
+ }, z.core.$strict>>;
54
+ webSearch: z.ZodDefault<z.ZodObject<{
55
+ braveApiKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
56
+ }, z.core.$strict>>;
57
+ }, z.core.$strict>>;
58
+ skills: z.ZodDefault<z.ZodObject<{
59
+ entries: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
60
+ enabled: z.ZodDefault<z.ZodBoolean>;
61
+ apiKey: z.ZodOptional<z.ZodString>;
62
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
63
+ }, z.core.$strict>>>;
64
+ }, z.core.$strict>>;
65
+ logging: z.ZodDefault<z.ZodObject<{
66
+ level: z.ZodDefault<z.ZodEnum<{
67
+ debug: "debug";
68
+ info: "info";
69
+ warn: "warn";
70
+ error: "error";
71
+ }>>;
72
+ format: z.ZodDefault<z.ZodEnum<{
73
+ json: "json";
74
+ pretty: "pretty";
75
+ }>>;
76
+ output: z.ZodDefault<z.ZodString>;
77
+ redact: z.ZodDefault<z.ZodArray<z.ZodString>>;
78
+ includeTimestamps: z.ZodDefault<z.ZodBoolean>;
79
+ includeHostname: z.ZodDefault<z.ZodBoolean>;
80
+ }, z.core.$strict>>;
81
+ heartbeat: z.ZodDefault<z.ZodObject<{
82
+ enabled: z.ZodDefault<z.ZodBoolean>;
83
+ intervalMinutes: z.ZodDefault<z.ZodNumber>;
84
+ activeHours: z.ZodDefault<z.ZodObject<{
85
+ start: z.ZodDefault<z.ZodNullable<z.ZodString>>;
86
+ end: z.ZodDefault<z.ZodNullable<z.ZodString>>;
87
+ }, z.core.$strict>>;
88
+ prompt: z.ZodDefault<z.ZodString>;
89
+ }, z.core.$strict>>;
90
+ }, z.core.$strict>;
91
+
92
+ type BabyclawConfig = z.infer<typeof babyclawConfigSchema>;
93
+
94
+ type GatewayStatus = {
95
+ state: "stopped" | "starting" | "running" | "stopping";
96
+ uptimeMs: number | null;
97
+ configPath: string | null;
98
+ pid: number;
99
+ version: string;
100
+ };
101
+ declare class GatewayRuntime {
102
+ private state;
103
+ private startedAt;
104
+ private config;
105
+ private log;
106
+ private db;
107
+ private schedulerRuntime;
108
+ private heartbeatRuntime;
109
+ private adminServer;
110
+ private channelRouter;
111
+ private memoryExtractionQueue;
112
+ start(): Promise<void>;
113
+ stop(): Promise<void>;
114
+ getStatus(): GatewayStatus;
115
+ getConfig(): BabyclawConfig | null;
116
+ registerSignalHandlers(): void;
117
+ }
118
+
119
+ type AdminClientInput = {
120
+ socketPath: string;
121
+ };
122
+ declare class AdminClient {
123
+ private readonly socketPath;
124
+ constructor({ socketPath }: AdminClientInput);
125
+ status(): Promise<{
126
+ state: string;
127
+ uptimeMs: number | null;
128
+ version: string;
129
+ pid: number;
130
+ }>;
131
+ health(): Promise<{
132
+ ok: boolean;
133
+ }>;
134
+ shutdown(): Promise<{
135
+ ok: boolean;
136
+ }>;
137
+ private get;
138
+ }
139
+
140
+ declare function getAdminSocketPath(): string;
141
+
142
+ declare function loadConfig(): Promise<BabyclawConfig>;
143
+ declare function loadConfigRaw(): Promise<BabyclawConfig | null>;
144
+ declare function writeConfig({ config }: {
145
+ config: BabyclawConfig;
146
+ }): Promise<void>;
147
+
148
+ declare const CONFIG_PATH_ENV_VAR = "BABYCLAW_CONFIG_PATH";
149
+ declare function getDefaultConfigPath(): string;
150
+ declare function getConfigPath(): string;
151
+
152
+ declare function getDefaultConfigTemplate(): string;
153
+
154
+ type InstallSkillResult = {
155
+ slug: string;
156
+ version: string;
157
+ displayName: string;
158
+ files: string[];
159
+ skillPath: string;
160
+ };
161
+ declare class SkillAlreadyInstalledError extends Error {
162
+ readonly slug: string;
163
+ readonly skillPath: string;
164
+ constructor({ slug, skillPath }: {
165
+ slug: string;
166
+ skillPath: string;
167
+ });
168
+ }
169
+ declare function installSkillFromClawHub({ slug, version, workspacePath, force, }: {
170
+ slug: string;
171
+ version?: string;
172
+ workspacePath: string;
173
+ force?: boolean;
174
+ }): Promise<InstallSkillResult>;
175
+
176
+ declare class ClawHubError extends Error {
177
+ readonly statusCode: number;
178
+ readonly slug: string;
179
+ constructor({ statusCode, slug, message, }: {
180
+ statusCode: number;
181
+ slug: string;
182
+ message: string;
183
+ });
184
+ }
185
+
186
+ type SkillSetupResult = {
187
+ skipped: boolean;
188
+ agentResponse: string;
189
+ };
190
+ type RunSkillSetupInput = {
191
+ model: LanguageModel;
192
+ skillPath: string;
193
+ workspacePath: string;
194
+ };
195
+ declare function runSkillSetup({ model, skillPath, workspacePath, }: RunSkillSetupInput): Promise<SkillSetupResult>;
196
+
197
+ type ProviderMeta = {
198
+ id: string;
199
+ displayName: string;
200
+ exampleModels: string[];
201
+ };
202
+ declare const SUPPORTED_PROVIDERS: ProviderMeta[];
203
+ declare function resolveLanguageModel({ config }: {
204
+ config: BabyclawConfig;
205
+ }): LanguageModel;
206
+
207
+ declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
208
+ type LogLevel = (typeof LOG_LEVELS)[number];
209
+ declare const LOG_FORMATS: readonly ["json", "pretty"];
210
+ type LogFormat = (typeof LOG_FORMATS)[number];
211
+ type LoggingConfig = {
212
+ level: LogLevel;
213
+ format: LogFormat;
214
+ output: string;
215
+ redact: string[];
216
+ includeTimestamps: boolean;
217
+ includeHostname: boolean;
218
+ };
219
+
220
+ declare function createLogger({ config }: {
221
+ config?: Partial<LoggingConfig>;
222
+ }): pino.Logger;
223
+ declare function getLogger(): pino.Logger;
224
+ declare function createChildLogger({ context }: {
225
+ context: Record<string, unknown>;
226
+ }): pino.Logger;
227
+
228
+ export { AdminClient, type BabyclawConfig, CONFIG_PATH_ENV_VAR, ClawHubError, GatewayRuntime, type GatewayStatus, type InstallSkillResult, type LogFormat, type LogLevel, type LoggingConfig, SUPPORTED_PROVIDERS, SkillAlreadyInstalledError, type SkillSetupResult, babyclawConfigSchema, createChildLogger, createLogger, getAdminSocketPath, getConfigPath, getDefaultConfigPath, getDefaultConfigTemplate, getLogger, installSkillFromClawHub, loadConfig, loadConfigRaw, resolveLanguageModel, runSkillSetup, writeConfig };