@lobu/core 3.0.13 → 3.0.19

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 (67) hide show
  1. package/dist/__tests__/fixtures/mock-redis.d.ts +3 -0
  2. package/dist/__tests__/fixtures/mock-redis.d.ts.map +1 -1
  3. package/dist/__tests__/fixtures/mock-redis.js +12 -0
  4. package/dist/__tests__/fixtures/mock-redis.js.map +1 -1
  5. package/dist/__tests__/secret-refs.test.d.ts +2 -0
  6. package/dist/__tests__/secret-refs.test.d.ts.map +1 -0
  7. package/dist/__tests__/secret-refs.test.js +29 -0
  8. package/dist/__tests__/secret-refs.test.js.map +1 -0
  9. package/dist/agent-store.d.ts +33 -6
  10. package/dist/agent-store.d.ts.map +1 -1
  11. package/dist/agent-store.js.map +1 -1
  12. package/dist/api-types.d.ts +1 -5
  13. package/dist/api-types.d.ts.map +1 -1
  14. package/dist/index.d.ts +5 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/integration-types.d.ts +9 -1
  19. package/dist/integration-types.d.ts.map +1 -1
  20. package/dist/lobu-toml-schema.d.ts +168 -0
  21. package/dist/lobu-toml-schema.d.ts.map +1 -0
  22. package/dist/lobu-toml-schema.js +108 -0
  23. package/dist/lobu-toml-schema.js.map +1 -0
  24. package/dist/secret-refs.d.ts +11 -0
  25. package/dist/secret-refs.d.ts.map +1 -0
  26. package/dist/secret-refs.js +31 -0
  27. package/dist/secret-refs.js.map +1 -0
  28. package/dist/types.d.ts +29 -8
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js +5 -3
  31. package/dist/types.js.map +1 -1
  32. package/package.json +14 -4
  33. package/src/__tests__/encryption.test.ts +0 -103
  34. package/src/__tests__/fixtures/factories.ts +0 -76
  35. package/src/__tests__/fixtures/index.ts +0 -9
  36. package/src/__tests__/fixtures/mock-fetch.ts +0 -32
  37. package/src/__tests__/fixtures/mock-queue.ts +0 -50
  38. package/src/__tests__/fixtures/mock-redis.ts +0 -300
  39. package/src/__tests__/retry.test.ts +0 -134
  40. package/src/__tests__/sanitize.test.ts +0 -158
  41. package/src/agent-policy.ts +0 -207
  42. package/src/agent-store.ts +0 -220
  43. package/src/api-types.ts +0 -256
  44. package/src/command-registry.ts +0 -73
  45. package/src/constants.ts +0 -60
  46. package/src/errors.ts +0 -220
  47. package/src/index.ts +0 -131
  48. package/src/integration-types.ts +0 -26
  49. package/src/logger.ts +0 -248
  50. package/src/modules.ts +0 -184
  51. package/src/otel.ts +0 -307
  52. package/src/plugin-types.ts +0 -46
  53. package/src/provider-config-types.ts +0 -54
  54. package/src/redis/base-store.ts +0 -200
  55. package/src/sentry.ts +0 -56
  56. package/src/trace.ts +0 -32
  57. package/src/types.ts +0 -440
  58. package/src/utils/encryption.ts +0 -78
  59. package/src/utils/env.ts +0 -50
  60. package/src/utils/json.ts +0 -37
  61. package/src/utils/lock.ts +0 -75
  62. package/src/utils/mcp-tool-instructions.ts +0 -5
  63. package/src/utils/retry.ts +0 -91
  64. package/src/utils/sanitize.ts +0 -127
  65. package/src/worker/auth.ts +0 -100
  66. package/src/worker/transport.ts +0 -107
  67. package/tsconfig.json +0 -20
@@ -1,73 +0,0 @@
1
- import { createLogger } from "./logger";
2
-
3
- const logger = createLogger("command-registry");
4
-
5
- /**
6
- * Context passed to command handlers.
7
- * Shaped to match OpenClaw's registerCommand() API for future migration.
8
- */
9
- export interface CommandContext {
10
- userId: string;
11
- channelId: string;
12
- conversationId?: string;
13
- connectionId?: string;
14
- agentId?: string;
15
- args: string;
16
- reply: (
17
- text: string,
18
- options?: { url?: string; urlLabel?: string; webApp?: boolean }
19
- ) => Promise<void>;
20
- platform: string;
21
- }
22
-
23
- /**
24
- * A registered command definition.
25
- */
26
- export interface CommandDefinition {
27
- name: string;
28
- description: string;
29
- handler: (ctx: CommandContext) => Promise<void>;
30
- }
31
-
32
- /**
33
- * Shared command registry used by all platform adapters.
34
- * Matches OpenClaw's registerCommand() shape so migration is a simple swap.
35
- */
36
- export class CommandRegistry {
37
- private commands = new Map<string, CommandDefinition>();
38
-
39
- register(cmd: CommandDefinition): void {
40
- this.commands.set(cmd.name, cmd);
41
- logger.debug({ command: cmd.name }, "Command registered");
42
- }
43
-
44
- get(name: string): CommandDefinition | undefined {
45
- return this.commands.get(name);
46
- }
47
-
48
- getAll(): CommandDefinition[] {
49
- return Array.from(this.commands.values());
50
- }
51
-
52
- /**
53
- * Try to handle a command by name. Returns true if handled.
54
- */
55
- async tryHandle(name: string, ctx: CommandContext): Promise<boolean> {
56
- const cmd = this.commands.get(name);
57
- if (!cmd) return false;
58
-
59
- try {
60
- await cmd.handler(ctx);
61
- return true;
62
- } catch (error) {
63
- logger.error(
64
- { command: name, error: String(error) },
65
- "Command handler failed"
66
- );
67
- await ctx.reply(
68
- "Sorry, something went wrong executing that command. Please try again."
69
- );
70
- return true;
71
- }
72
- }
73
- }
package/src/constants.ts DELETED
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- /**
4
- * Shared constants across all packages
5
- * These are platform-agnostic and used by core, gateway, and platform adapters
6
- */
7
-
8
- // Time constants (milliseconds)
9
- export const TIME = {
10
- /** One hour in milliseconds */
11
- HOUR_MS: 60 * 60 * 1000,
12
- /** One day in milliseconds */
13
- DAY_MS: 24 * 60 * 60 * 1000,
14
- /** One hour in seconds */
15
- HOUR_SECONDS: 3600,
16
- /** One day in seconds */
17
- DAY_SECONDS: 24 * 60 * 60,
18
- /** One minute in milliseconds */
19
- MINUTE_MS: 60 * 1000,
20
- /** Five seconds in milliseconds */
21
- FIVE_SECONDS_MS: 5000,
22
- /** Thirty seconds */
23
- THIRTY_SECONDS: 30,
24
- /** Three hours in milliseconds (for interaction timeout) */
25
- THREE_HOURS_MS: 3 * 60 * 60 * 1000,
26
- /** Three hours in seconds (for Redis TTL) */
27
- THREE_HOURS_SECONDS: 3 * 60 * 60,
28
- } as const;
29
-
30
- // Redis key prefixes
31
- export const REDIS_KEYS = {
32
- /** Prefix for bot message timestamps */
33
- BOT_MESSAGES: "bot_messages:",
34
- /** Prefix for session data */
35
- SESSION: "session:",
36
- /** Prefix for thread ownership */
37
- THREAD_OWNER: "thread_owner:",
38
- /** Prefix for MCP credentials */
39
- MCP_CREDENTIAL: "mcp:credential:",
40
- /** Prefix for MCP OAuth state */
41
- MCP_OAUTH_STATE: "mcp:oauth:state:",
42
- /** Prefix for MCP inputs */
43
- MCP_INPUT: "mcp:input:",
44
- } as const;
45
-
46
- // Default configuration values
47
- export const DEFAULTS = {
48
- /** Default session TTL in milliseconds */
49
- SESSION_TTL_MS: TIME.DAY_MS,
50
- /** Default session TTL in seconds */
51
- SESSION_TTL_SECONDS: TIME.DAY_SECONDS,
52
- /** Default queue expiration in hours */
53
- QUEUE_EXPIRE_HOURS: 24,
54
- /** Default retry limit for queue operations */
55
- QUEUE_RETRY_LIMIT: 3,
56
- /** Default retry delay in seconds */
57
- QUEUE_RETRY_DELAY_SECONDS: TIME.THIRTY_SECONDS,
58
- /** Default session timeout in minutes */
59
- SESSION_TIMEOUT_MINUTES: 5,
60
- } as const;
package/src/errors.ts DELETED
@@ -1,220 +0,0 @@
1
- /**
2
- * Base error class for all lobu errors
3
- */
4
- export abstract class BaseError extends Error {
5
- abstract readonly name: string;
6
- public operation?: string;
7
-
8
- constructor(
9
- message: string,
10
- public cause?: Error
11
- ) {
12
- super(message);
13
-
14
- // Maintain proper prototype chain for instanceof checks
15
- Object.setPrototypeOf(this, new.target.prototype);
16
- }
17
-
18
- /**
19
- * Get the full error chain as a string
20
- */
21
- getFullMessage(): string {
22
- let message = `${this.name}: ${this.message}`;
23
- if (this.cause) {
24
- if (this.cause instanceof BaseError) {
25
- message += `\nCaused by: ${this.cause.getFullMessage()}`;
26
- } else {
27
- message += `\nCaused by: ${this.cause.message}`;
28
- }
29
- }
30
- return message;
31
- }
32
-
33
- /**
34
- * Convert error to JSON for logging/serialization
35
- */
36
- toJSON(): Record<string, any> {
37
- return {
38
- name: this.name,
39
- message: this.message,
40
- ...(this.operation && { operation: this.operation }),
41
- cause:
42
- this.cause instanceof BaseError
43
- ? this.cause.toJSON()
44
- : this.cause?.message,
45
- stack: this.stack,
46
- };
47
- }
48
- }
49
-
50
- /**
51
- * Error class for worker-related operations
52
- */
53
- export class WorkerError extends BaseError {
54
- override readonly name = "WorkerError";
55
-
56
- constructor(operation: string, message: string, cause?: Error) {
57
- super(message, cause);
58
- this.operation = operation;
59
- }
60
- }
61
-
62
- /**
63
- * Error class for workspace-related operations
64
- */
65
- export class WorkspaceError extends BaseError {
66
- override readonly name = "WorkspaceError";
67
-
68
- constructor(operation: string, message: string, cause?: Error) {
69
- super(message, cause);
70
- this.operation = operation;
71
- }
72
- }
73
-
74
- /**
75
- * Error class for platform-related operations (Slack, WhatsApp, etc.)
76
- */
77
- export class PlatformError extends BaseError {
78
- override readonly name = "PlatformError";
79
-
80
- constructor(
81
- public platform: string,
82
- operation: string,
83
- message: string,
84
- cause?: Error
85
- ) {
86
- super(message, cause);
87
- this.operation = operation;
88
- }
89
-
90
- override toJSON(): Record<string, any> {
91
- return {
92
- ...super.toJSON(),
93
- platform: this.platform,
94
- };
95
- }
96
- }
97
-
98
- /**
99
- * Error class for session-related operations
100
- */
101
- export class SessionError extends BaseError {
102
- readonly name = "SessionError";
103
-
104
- constructor(
105
- public sessionKey: string,
106
- public code: string,
107
- message: string,
108
- cause?: Error
109
- ) {
110
- super(message, cause);
111
- }
112
-
113
- toJSON(): Record<string, any> {
114
- return {
115
- ...super.toJSON(),
116
- sessionKey: this.sessionKey,
117
- code: this.code,
118
- };
119
- }
120
- }
121
-
122
- /**
123
- * Worker error variant with workerId for core operations
124
- */
125
- export class CoreWorkerError extends WorkerError {
126
- constructor(
127
- public workerId: string,
128
- operation: string,
129
- message: string,
130
- cause?: Error
131
- ) {
132
- super(operation, message, cause);
133
- }
134
-
135
- override toJSON(): Record<string, any> {
136
- return {
137
- ...super.toJSON(),
138
- workerId: this.workerId,
139
- };
140
- }
141
- }
142
-
143
- /**
144
- * Error class for dispatcher-related operations
145
- */
146
- export class DispatcherError extends BaseError {
147
- override readonly name = "DispatcherError";
148
-
149
- constructor(operation: string, message: string, cause?: Error) {
150
- super(message, cause);
151
- this.operation = operation;
152
- }
153
- }
154
-
155
- // ErrorCode enum for orchestration operations
156
- export enum ErrorCode {
157
- DATABASE_CONNECTION_FAILED = "DATABASE_CONNECTION_FAILED",
158
- KUBERNETES_API_ERROR = "KUBERNETES_API_ERROR",
159
- DEPLOYMENT_SCALE_FAILED = "DEPLOYMENT_SCALE_FAILED",
160
- DEPLOYMENT_CREATE_FAILED = "DEPLOYMENT_CREATE_FAILED",
161
- DEPLOYMENT_DELETE_FAILED = "DEPLOYMENT_DELETE_FAILED",
162
- QUEUE_JOB_PROCESSING_FAILED = "QUEUE_JOB_PROCESSING_FAILED",
163
- USER_CREDENTIALS_CREATE_FAILED = "USER_CREDENTIALS_CREATE_FAILED",
164
- INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
165
- THREAD_DEPLOYMENT_NOT_FOUND = "THREAD_DEPLOYMENT_NOT_FOUND",
166
- USER_QUEUE_NOT_FOUND = "USER_QUEUE_NOT_FOUND",
167
- }
168
-
169
- /**
170
- * Error class for orchestrator-related operations
171
- */
172
- export class OrchestratorError extends BaseError {
173
- readonly name = "OrchestratorError";
174
-
175
- constructor(
176
- public code: ErrorCode,
177
- message: string,
178
- public details?: any,
179
- public shouldRetry: boolean = false,
180
- cause?: Error
181
- ) {
182
- super(message, cause);
183
- }
184
-
185
- static fromDatabaseError(error: any): OrchestratorError {
186
- return new OrchestratorError(
187
- ErrorCode.DATABASE_CONNECTION_FAILED,
188
- `Database error: ${error instanceof Error ? error.message : String(error)}`,
189
- { code: error.code, detail: error.detail },
190
- true,
191
- error
192
- );
193
- }
194
-
195
- static fromKubernetesError(error: any): OrchestratorError {
196
- return new OrchestratorError(
197
- ErrorCode.KUBERNETES_API_ERROR,
198
- `Kubernetes operation failed: ${error.message}`,
199
- error,
200
- true,
201
- error
202
- );
203
- }
204
-
205
- toJSON(): Record<string, any> {
206
- return {
207
- ...super.toJSON(),
208
- code: this.code,
209
- details: this.details,
210
- shouldRetry: this.shouldRetry,
211
- };
212
- }
213
- }
214
-
215
- /**
216
- * Error class for configuration-related operations
217
- */
218
- export class ConfigError extends BaseError {
219
- readonly name = "ConfigError";
220
- }
package/src/index.ts DELETED
@@ -1,131 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- // Shared exports for @lobu/core consumers (gateway, worker, external tools)
4
-
5
- export * from "./agent-policy";
6
- // Agent store interface (unified storage abstraction)
7
- export type {
8
- AgentAccessStore,
9
- AgentConfigStore,
10
- AgentConnectionStore,
11
- AgentMetadata,
12
- AgentSettings,
13
- AgentStore,
14
- ChannelBinding,
15
- ConnectionSettings,
16
- Grant,
17
- StoredConnection,
18
- } from "./agent-store";
19
- export { findTemplateAgentId } from "./agent-store";
20
- // Agent Settings API response types (for UI consumers)
21
- export type {
22
- AgentConfigResponse,
23
- AgentInfo,
24
- CatalogProvider,
25
- Connection,
26
- McpConfig,
27
- ModelOption,
28
- ModelSelectionState,
29
- PermissionGrant,
30
- PrefillMcp,
31
- PrefillSkill,
32
- ProviderInfo,
33
- ProviderState,
34
- ProviderStatus,
35
- Schedule,
36
- SettingsSnapshot,
37
- Skill,
38
- SkillMcpServerInfo,
39
- } from "./api-types";
40
- export type { CommandContext, CommandDefinition } from "./command-registry";
41
- // Command registry
42
- export { CommandRegistry } from "./command-registry";
43
- export * from "./constants";
44
- // Errors & logging
45
- export * from "./errors";
46
- // Integration types
47
- export type {
48
- SystemSkillEntry,
49
- SystemSkillsConfigFile,
50
- } from "./integration-types";
51
- export * from "./logger";
52
- // Module system
53
- export type { ActionButton, ModuleSessionContext } from "./modules";
54
- export * from "./modules";
55
- export type { OtelConfig, Span, Tracer } from "./otel";
56
- // OpenTelemetry tracing
57
- export {
58
- createChildSpan,
59
- createRootSpan,
60
- createSpan,
61
- flushTracing,
62
- getCurrentSpan,
63
- getTraceparent,
64
- getTracer,
65
- initTracing,
66
- runInSpanContext,
67
- SpanKind,
68
- SpanStatusCode,
69
- shutdownTracing,
70
- withChildSpan,
71
- withSpan,
72
- } from "./otel";
73
- // Plugin types
74
- export type {
75
- PluginConfig,
76
- PluginManifest,
77
- PluginSlot,
78
- PluginsConfig,
79
- ProviderRegistration,
80
- } from "./plugin-types";
81
- // Config-driven provider types
82
- export type {
83
- ConfigProviderMeta,
84
- ProviderConfigEntry,
85
- } from "./provider-config-types";
86
- // Redis & worker helpers
87
- export * from "./redis/base-store";
88
- // Observability
89
- export { getSentry, initSentry } from "./sentry";
90
- export { extractTraceId, generateTraceId } from "./trace";
91
- // Core types
92
- export type {
93
- AgentMcpConfig,
94
- AgentOptions,
95
- AuthProfile,
96
- CliBackendConfig,
97
- ConversationMessage,
98
- HistoryMessage,
99
- InstalledProvider,
100
- InstructionContext,
101
- InstructionProvider,
102
- LogLevel,
103
- McpOAuthConfig,
104
- McpServerConfig,
105
- NetworkConfig,
106
- NixConfig,
107
- RegistryEntry,
108
- SessionContext,
109
- SkillConfig,
110
- SkillMcpServer,
111
- SkillsConfig,
112
- SuggestedPrompt,
113
- ThinkingLevel,
114
- ThreadResponsePayload,
115
- ToolsConfig,
116
- UserSuggestion,
117
- } from "./types";
118
-
119
- // Utilities
120
- export * from "./utils/encryption";
121
- export * from "./utils/env";
122
- export * from "./utils/json";
123
- export * from "./utils/lock";
124
- export type { McpToolDef } from "./utils/mcp-tool-instructions";
125
- export * from "./utils/retry";
126
- export * from "./utils/sanitize";
127
- export * from "./worker/auth";
128
- export type {
129
- WorkerTransport,
130
- WorkerTransportConfig,
131
- } from "./worker/transport";
@@ -1,26 +0,0 @@
1
- /**
2
- * Shared types for the integration system.
3
- *
4
- * OAuth credential management for third-party APIs (GitHub, Google, etc.)
5
- * is handled by Owletto.
6
- */
7
-
8
- import type { ProviderConfigEntry } from "./provider-config-types";
9
-
10
- // System Skills Config (config/system-skills.json)
11
-
12
- export interface SystemSkillEntry {
13
- id: string;
14
- name: string;
15
- description?: string;
16
- instructions?: string;
17
- hidden?: boolean;
18
- mcpServers?: import("./types").SkillMcpServer[];
19
- providers?: ProviderConfigEntry[];
20
- nixPackages?: string[];
21
- permissions?: string[];
22
- }
23
-
24
- export interface SystemSkillsConfigFile {
25
- skills: SystemSkillEntry[];
26
- }