@lobu/worker 3.0.8 → 3.0.12

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 (52) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +4 -6
  3. package/dist/index.js.map +1 -1
  4. package/dist/openclaw/session-context.d.ts.map +1 -1
  5. package/dist/openclaw/session-context.js +1 -1
  6. package/dist/openclaw/session-context.js.map +1 -1
  7. package/package.json +2 -2
  8. package/USAGE.md +0 -120
  9. package/docs/custom-base-image.md +0 -88
  10. package/scripts/worker-entrypoint.sh +0 -184
  11. package/src/__tests__/audio-provider-suggestions.test.ts +0 -198
  12. package/src/__tests__/embedded-just-bash-bootstrap.test.ts +0 -39
  13. package/src/__tests__/embedded-tools.test.ts +0 -558
  14. package/src/__tests__/instructions.test.ts +0 -59
  15. package/src/__tests__/memory-flush-runtime.test.ts +0 -138
  16. package/src/__tests__/memory-flush.test.ts +0 -64
  17. package/src/__tests__/model-resolver.test.ts +0 -156
  18. package/src/__tests__/processor.test.ts +0 -225
  19. package/src/__tests__/setup.ts +0 -109
  20. package/src/__tests__/sse-client.test.ts +0 -48
  21. package/src/__tests__/tool-policy.test.ts +0 -269
  22. package/src/__tests__/worker.test.ts +0 -89
  23. package/src/core/error-handler.ts +0 -70
  24. package/src/core/project-scanner.ts +0 -65
  25. package/src/core/types.ts +0 -125
  26. package/src/core/url-utils.ts +0 -9
  27. package/src/core/workspace.ts +0 -138
  28. package/src/embedded/just-bash-bootstrap.ts +0 -228
  29. package/src/gateway/gateway-integration.ts +0 -287
  30. package/src/gateway/message-batcher.ts +0 -128
  31. package/src/gateway/sse-client.ts +0 -955
  32. package/src/gateway/types.ts +0 -68
  33. package/src/index.ts +0 -146
  34. package/src/instructions/builder.ts +0 -80
  35. package/src/instructions/providers.ts +0 -27
  36. package/src/modules/lifecycle.ts +0 -92
  37. package/src/openclaw/custom-tools.ts +0 -290
  38. package/src/openclaw/instructions.ts +0 -38
  39. package/src/openclaw/model-resolver.ts +0 -150
  40. package/src/openclaw/plugin-loader.ts +0 -427
  41. package/src/openclaw/processor.ts +0 -216
  42. package/src/openclaw/session-context.ts +0 -277
  43. package/src/openclaw/tool-policy.ts +0 -212
  44. package/src/openclaw/tools.ts +0 -208
  45. package/src/openclaw/worker.ts +0 -1792
  46. package/src/server.ts +0 -329
  47. package/src/shared/audio-provider-suggestions.ts +0 -132
  48. package/src/shared/processor-utils.ts +0 -33
  49. package/src/shared/provider-auth-hints.ts +0 -64
  50. package/src/shared/tool-display-config.ts +0 -75
  51. package/src/shared/tool-implementations.ts +0 -768
  52. package/tsconfig.json +0 -21
@@ -1,128 +0,0 @@
1
- /**
2
- * Message batching for grouping rapid messages
3
- */
4
-
5
- import { createLogger } from "@lobu/core";
6
- import type { QueuedMessage } from "./types";
7
-
8
- const logger = createLogger("message-batcher");
9
-
10
- interface BatcherConfig {
11
- onBatchReady?: (messages: QueuedMessage[]) => Promise<void>;
12
- batchWindowMs?: number;
13
- }
14
-
15
- /**
16
- * Simple message batcher - collects messages for a short window, then processes
17
- */
18
- export class MessageBatcher {
19
- private messageQueue: QueuedMessage[] = [];
20
- private isProcessing = false;
21
- private batchTimer: NodeJS.Timeout | null = null;
22
- private readonly batchWindowMs: number;
23
- private readonly onBatchReady?: (messages: QueuedMessage[]) => Promise<void>;
24
- private hasProcessedInitialBatch = false;
25
-
26
- constructor(config: BatcherConfig = {}) {
27
- this.batchWindowMs = config.batchWindowMs ?? 2000; // 2 second window by default
28
- this.onBatchReady = config.onBatchReady;
29
- }
30
-
31
- async addMessage(message: QueuedMessage): Promise<void> {
32
- this.messageQueue.push(message);
33
-
34
- // If already processing, message will be picked up in next batch
35
- if (this.isProcessing) {
36
- logger.info(
37
- `Message queued (${this.messageQueue.length} pending, processing in progress)`
38
- );
39
- return;
40
- }
41
-
42
- // If no batch timer running, start one
43
- if (!this.batchTimer) {
44
- if (!this.hasProcessedInitialBatch) {
45
- this.hasProcessedInitialBatch = true;
46
- logger.info(
47
- `Processing first message immediately (skipping ${this.batchWindowMs}ms batch window)`
48
- );
49
- await this.processBatch();
50
- return;
51
- }
52
-
53
- logger.info(
54
- `Starting ${this.batchWindowMs}ms batch window (${this.messageQueue.length} message(s))`
55
- );
56
- this.batchTimer = setTimeout(() => {
57
- void this.processBatch().catch(() => {
58
- // Error already logged in processBatch
59
- });
60
- }, this.batchWindowMs);
61
- } else {
62
- logger.info(
63
- `Message added to batch window (${this.messageQueue.length} pending)`
64
- );
65
- }
66
- }
67
-
68
- private async processBatch(): Promise<void> {
69
- if (this.batchTimer) {
70
- clearTimeout(this.batchTimer);
71
- this.batchTimer = null;
72
- }
73
-
74
- if (this.messageQueue.length === 0) {
75
- return;
76
- }
77
-
78
- this.isProcessing = true;
79
-
80
- try {
81
- const messagesToProcess = [...this.messageQueue];
82
- this.messageQueue = [];
83
-
84
- logger.info(`Processing batch of ${messagesToProcess.length} messages`);
85
- messagesToProcess.sort((a, b) => a.timestamp - b.timestamp);
86
-
87
- if (this.onBatchReady) {
88
- await this.onBatchReady(messagesToProcess);
89
- }
90
-
91
- // If more messages arrived during processing, start new batch
92
- if (this.messageQueue.length > 0) {
93
- if (this.batchTimer) {
94
- clearTimeout(this.batchTimer);
95
- this.batchTimer = null;
96
- }
97
- logger.info(
98
- `Starting new batch window for ${this.messageQueue.length} queued messages`
99
- );
100
- this.batchTimer = setTimeout(() => {
101
- void this.processBatch().catch(() => {
102
- // Error already logged in processBatch
103
- });
104
- }, this.batchWindowMs);
105
- }
106
- } catch (error) {
107
- logger.error("Error during batch processing:", error);
108
- throw error;
109
- } finally {
110
- this.isProcessing = false;
111
- }
112
- }
113
-
114
- stop(): void {
115
- if (this.batchTimer) {
116
- clearTimeout(this.batchTimer);
117
- this.batchTimer = null;
118
- }
119
- }
120
-
121
- isCurrentlyProcessing(): boolean {
122
- return this.isProcessing;
123
- }
124
-
125
- getPendingCount(): number {
126
- return this.messageQueue.length;
127
- }
128
- }