crawd 0.8.5 → 0.8.6
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.
- package/dist/backend/index.js +3 -5
- package/dist/plugin.js +3 -32
- package/package.json +1 -1
- package/src/backend/coordinator.ts +3 -7
- package/src/plugin.ts +0 -30
package/dist/backend/index.js
CHANGED
|
@@ -11205,14 +11205,13 @@ var YouTubeChatClient = class extends BaseChatClient {
|
|
|
11205
11205
|
// src/backend/coordinator.ts
|
|
11206
11206
|
import { randomUUID } from "crypto";
|
|
11207
11207
|
import WebSocket from "ws";
|
|
11208
|
-
var
|
|
11208
|
+
var BATCH_WINDOW_MS = 2e4;
|
|
11209
11209
|
var SESSION_KEY = process.env.CRAWD_CHANNEL_ID || "agent:main:crawd:live";
|
|
11210
11210
|
var DEFAULT_CONFIG = {
|
|
11211
11211
|
vibeEnabled: true,
|
|
11212
11212
|
vibeIntervalMs: 3e4,
|
|
11213
11213
|
idleAfterMs: 18e4,
|
|
11214
11214
|
sleepAfterIdleMs: 18e4,
|
|
11215
|
-
chatBatchWindowMs: DEFAULT_BATCH_WINDOW_MS,
|
|
11216
11215
|
vibePrompt: `[CRAWD:VIBE] You are on a livestream. Make sure the crawd skill is loaded. Do one thing on the internet or ask the chat something. Respond with LIVESTREAM_REPLIED after using a tool, or NO_REPLY if you have nothing to say.`
|
|
11217
11216
|
};
|
|
11218
11217
|
var realClock = {
|
|
@@ -11483,7 +11482,6 @@ var Coordinator = class _Coordinator {
|
|
|
11483
11482
|
this.config = { ...this.config, ...config2 };
|
|
11484
11483
|
this.logger.log("[Coordinator] Config updated:", {
|
|
11485
11484
|
vibeIntervalMs: this.config.vibeIntervalMs,
|
|
11486
|
-
chatBatchWindowMs: this.config.chatBatchWindowMs,
|
|
11487
11485
|
idleAfterMs: this.config.idleAfterMs,
|
|
11488
11486
|
sleepAfterIdleMs: this.config.sleepAfterIdleMs
|
|
11489
11487
|
});
|
|
@@ -11707,14 +11705,14 @@ var Coordinator = class _Coordinator {
|
|
|
11707
11705
|
}
|
|
11708
11706
|
if (!this.timer) {
|
|
11709
11707
|
this.flush();
|
|
11710
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
11708
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS);
|
|
11711
11709
|
}
|
|
11712
11710
|
}
|
|
11713
11711
|
onCooldownEnd() {
|
|
11714
11712
|
this.timer = null;
|
|
11715
11713
|
if (this.buffer.length > 0) {
|
|
11716
11714
|
this.flush();
|
|
11717
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
11715
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS);
|
|
11718
11716
|
}
|
|
11719
11717
|
}
|
|
11720
11718
|
/** Whether the coordinator is busy processing a flush or talk */
|
package/dist/plugin.js
CHANGED
|
@@ -11206,14 +11206,13 @@ var YouTubeChatClient = class extends BaseChatClient {
|
|
|
11206
11206
|
// src/backend/coordinator.ts
|
|
11207
11207
|
import { randomUUID } from "crypto";
|
|
11208
11208
|
import WebSocket from "ws";
|
|
11209
|
-
var
|
|
11209
|
+
var BATCH_WINDOW_MS = 2e4;
|
|
11210
11210
|
var SESSION_KEY = process.env.CRAWD_CHANNEL_ID || "agent:main:crawd:live";
|
|
11211
11211
|
var DEFAULT_CONFIG = {
|
|
11212
11212
|
vibeEnabled: true,
|
|
11213
11213
|
vibeIntervalMs: 3e4,
|
|
11214
11214
|
idleAfterMs: 18e4,
|
|
11215
11215
|
sleepAfterIdleMs: 18e4,
|
|
11216
|
-
chatBatchWindowMs: DEFAULT_BATCH_WINDOW_MS,
|
|
11217
11216
|
vibePrompt: `[CRAWD:VIBE] You are on a livestream. Make sure the crawd skill is loaded. Do one thing on the internet or ask the chat something. Respond with LIVESTREAM_REPLIED after using a tool, or NO_REPLY if you have nothing to say.`
|
|
11218
11217
|
};
|
|
11219
11218
|
var realClock = {
|
|
@@ -11361,7 +11360,6 @@ var Coordinator = class _Coordinator {
|
|
|
11361
11360
|
this.config = { ...this.config, ...config2 };
|
|
11362
11361
|
this.logger.log("[Coordinator] Config updated:", {
|
|
11363
11362
|
vibeIntervalMs: this.config.vibeIntervalMs,
|
|
11364
|
-
chatBatchWindowMs: this.config.chatBatchWindowMs,
|
|
11365
11363
|
idleAfterMs: this.config.idleAfterMs,
|
|
11366
11364
|
sleepAfterIdleMs: this.config.sleepAfterIdleMs
|
|
11367
11365
|
});
|
|
@@ -11585,14 +11583,14 @@ var Coordinator = class _Coordinator {
|
|
|
11585
11583
|
}
|
|
11586
11584
|
if (!this.timer) {
|
|
11587
11585
|
this.flush();
|
|
11588
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
11586
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS);
|
|
11589
11587
|
}
|
|
11590
11588
|
}
|
|
11591
11589
|
onCooldownEnd() {
|
|
11592
11590
|
this.timer = null;
|
|
11593
11591
|
if (this.buffer.length > 0) {
|
|
11594
11592
|
this.flush();
|
|
11595
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
11593
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS);
|
|
11596
11594
|
}
|
|
11597
11595
|
}
|
|
11598
11596
|
/** Whether the coordinator is busy processing a flush or talk */
|
|
@@ -12324,33 +12322,6 @@ var plugin = {
|
|
|
12324
12322
|
},
|
|
12325
12323
|
{ name: "livestream_reply" }
|
|
12326
12324
|
);
|
|
12327
|
-
api.registerTool(
|
|
12328
|
-
{
|
|
12329
|
-
name: "livestream_config",
|
|
12330
|
-
label: "Livestream Config",
|
|
12331
|
-
description: "Update livestream coordinator settings at runtime. Use when asked to change vibe speed/frequency, chat throttle/batch window, idle timeout, or sleep timeout.",
|
|
12332
|
-
parameters: Type.Object({
|
|
12333
|
-
vibeIntervalMs: Type.Optional(Type.Number({ description: "Milliseconds between autonomous vibe prompts (lower = more frequent vibes)" })),
|
|
12334
|
-
chatBatchWindowMs: Type.Optional(Type.Number({ description: "Milliseconds to batch chat messages before sending to agent (lower = faster chat response, higher = more messages per batch)" })),
|
|
12335
|
-
idleAfterMs: Type.Optional(Type.Number({ description: "Milliseconds of inactivity before transitioning to idle state" })),
|
|
12336
|
-
sleepAfterIdleMs: Type.Optional(Type.Number({ description: "Milliseconds in idle before transitioning to sleep state" })),
|
|
12337
|
-
vibeEnabled: Type.Optional(Type.Boolean({ description: "Enable or disable autonomous vibe prompts" }))
|
|
12338
|
-
}),
|
|
12339
|
-
async execute(_toolCallId, params) {
|
|
12340
|
-
const b = await ensureBackend();
|
|
12341
|
-
if (!b.coordinator) {
|
|
12342
|
-
return { content: [{ type: "text", text: "Coordinator not running" }] };
|
|
12343
|
-
}
|
|
12344
|
-
const p = params;
|
|
12345
|
-
b.coordinator.updateConfig(p);
|
|
12346
|
-
const { state, config: cfg } = b.coordinator.getState();
|
|
12347
|
-
return {
|
|
12348
|
-
content: [{ type: "text", text: `Config updated. state=${state}, vibeInterval=${cfg.vibeIntervalMs}ms, chatBatch=${cfg.chatBatchWindowMs}ms, idleAfter=${cfg.idleAfterMs}ms, sleepAfter=${cfg.sleepAfterIdleMs}ms, vibes=${cfg.vibeEnabled}` }]
|
|
12349
|
-
};
|
|
12350
|
-
}
|
|
12351
|
-
},
|
|
12352
|
-
{ name: "livestream_config" }
|
|
12353
|
-
);
|
|
12354
12325
|
api.registerService({
|
|
12355
12326
|
id: "crawd",
|
|
12356
12327
|
start: async () => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from 'crypto'
|
|
|
2
2
|
import WebSocket from 'ws'
|
|
3
3
|
import type { ChatMessage } from '../lib/chat/types'
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const BATCH_WINDOW_MS = 20_000
|
|
6
6
|
const SESSION_KEY = process.env.CRAWD_CHANNEL_ID || 'agent:main:crawd:live'
|
|
7
7
|
|
|
8
8
|
/** Coordinator configuration */
|
|
@@ -15,8 +15,6 @@ export type CoordinatorConfig = {
|
|
|
15
15
|
idleAfterMs: number
|
|
16
16
|
/** Go sleep after this much inactivity while idle (ms). Default: 60000 (1 min) */
|
|
17
17
|
sleepAfterIdleMs: number
|
|
18
|
-
/** Chat message batching window (ms). Default: 20000 (20 sec) */
|
|
19
|
-
chatBatchWindowMs: number
|
|
20
18
|
/** The autonomous "vibe" prompt sent periodically */
|
|
21
19
|
vibePrompt: string
|
|
22
20
|
}
|
|
@@ -26,7 +24,6 @@ export const DEFAULT_CONFIG: CoordinatorConfig = {
|
|
|
26
24
|
vibeIntervalMs: 30_000,
|
|
27
25
|
idleAfterMs: 180_000,
|
|
28
26
|
sleepAfterIdleMs: 180_000,
|
|
29
|
-
chatBatchWindowMs: DEFAULT_BATCH_WINDOW_MS,
|
|
30
27
|
vibePrompt: `[CRAWD:VIBE] You are on a livestream. Make sure the crawd skill is loaded. Do one thing on the internet or ask the chat something. Respond with LIVESTREAM_REPLIED after using a tool, or NO_REPLY if you have nothing to say.`,
|
|
31
28
|
}
|
|
32
29
|
|
|
@@ -557,7 +554,6 @@ export class Coordinator {
|
|
|
557
554
|
this.config = { ...this.config, ...config }
|
|
558
555
|
this.logger.log('[Coordinator] Config updated:', {
|
|
559
556
|
vibeIntervalMs: this.config.vibeIntervalMs,
|
|
560
|
-
chatBatchWindowMs: this.config.chatBatchWindowMs,
|
|
561
557
|
idleAfterMs: this.config.idleAfterMs,
|
|
562
558
|
sleepAfterIdleMs: this.config.sleepAfterIdleMs,
|
|
563
559
|
})
|
|
@@ -840,7 +836,7 @@ export class Coordinator {
|
|
|
840
836
|
// Leading edge: if no timer running, flush immediately and start cooldown
|
|
841
837
|
if (!this.timer) {
|
|
842
838
|
this.flush()
|
|
843
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
839
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS)
|
|
844
840
|
}
|
|
845
841
|
// Otherwise, message is buffered and will be flushed when cooldown ends
|
|
846
842
|
}
|
|
@@ -851,7 +847,7 @@ export class Coordinator {
|
|
|
851
847
|
// If messages accumulated during cooldown, flush them and restart cooldown
|
|
852
848
|
if (this.buffer.length > 0) {
|
|
853
849
|
this.flush()
|
|
854
|
-
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(),
|
|
850
|
+
this.timer = this.clock.setTimeout(() => this.onCooldownEnd(), BATCH_WINDOW_MS)
|
|
855
851
|
}
|
|
856
852
|
}
|
|
857
853
|
|
package/src/plugin.ts
CHANGED
|
@@ -249,36 +249,6 @@ const plugin: PluginDefinition = {
|
|
|
249
249
|
{ name: 'livestream_reply' },
|
|
250
250
|
)
|
|
251
251
|
|
|
252
|
-
// livestream_config — runtime coordinator tuning
|
|
253
|
-
api.registerTool(
|
|
254
|
-
{
|
|
255
|
-
name: 'livestream_config',
|
|
256
|
-
label: 'Livestream Config',
|
|
257
|
-
description:
|
|
258
|
-
'Update livestream coordinator settings at runtime. Use when asked to change vibe speed/frequency, chat throttle/batch window, idle timeout, or sleep timeout.',
|
|
259
|
-
parameters: Type.Object({
|
|
260
|
-
vibeIntervalMs: Type.Optional(Type.Number({ description: 'Milliseconds between autonomous vibe prompts (lower = more frequent vibes)' })),
|
|
261
|
-
chatBatchWindowMs: Type.Optional(Type.Number({ description: 'Milliseconds to batch chat messages before sending to agent (lower = faster chat response, higher = more messages per batch)' })),
|
|
262
|
-
idleAfterMs: Type.Optional(Type.Number({ description: 'Milliseconds of inactivity before transitioning to idle state' })),
|
|
263
|
-
sleepAfterIdleMs: Type.Optional(Type.Number({ description: 'Milliseconds in idle before transitioning to sleep state' })),
|
|
264
|
-
vibeEnabled: Type.Optional(Type.Boolean({ description: 'Enable or disable autonomous vibe prompts' })),
|
|
265
|
-
}),
|
|
266
|
-
async execute(_toolCallId: string, params: unknown) {
|
|
267
|
-
const b = await ensureBackend()
|
|
268
|
-
if (!b.coordinator) {
|
|
269
|
-
return { content: [{ type: 'text', text: 'Coordinator not running' }] }
|
|
270
|
-
}
|
|
271
|
-
const p = params as Record<string, unknown>
|
|
272
|
-
b.coordinator.updateConfig(p)
|
|
273
|
-
const { state, config: cfg } = b.coordinator.getState()
|
|
274
|
-
return {
|
|
275
|
-
content: [{ type: 'text', text: `Config updated. state=${state}, vibeInterval=${cfg.vibeIntervalMs}ms, chatBatch=${cfg.chatBatchWindowMs}ms, idleAfter=${cfg.idleAfterMs}ms, sleepAfter=${cfg.sleepAfterIdleMs}ms, vibes=${cfg.vibeEnabled}` }],
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{ name: 'livestream_config' },
|
|
280
|
-
)
|
|
281
|
-
|
|
282
252
|
// Service lifecycle
|
|
283
253
|
api.registerService({
|
|
284
254
|
id: 'crawd',
|