@teamvibe/poller 0.1.55 → 0.1.57

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.
@@ -12,6 +12,7 @@ interface AuthConfig {
12
12
  export declare function initAuth(apiUrl: string, token: string): Promise<void>;
13
13
  export declare function getCredentials(): AuthCredentials;
14
14
  export declare function getAuthConfig(): AuthConfig;
15
+ export declare function getPollerId(): string | null;
15
16
  export declare function isTokenMode(): boolean;
16
17
  export declare function stopRefresh(): void;
17
18
  export {};
@@ -2,6 +2,7 @@ import { POLLER_VERSION } from './config.js';
2
2
  import { logger } from './logger.js';
3
3
  let currentCredentials = null;
4
4
  let currentConfig = null;
5
+ let currentPollerId = null;
5
6
  let refreshTimer = null;
6
7
  let heartbeatTimer = null;
7
8
  const REFRESH_INTERVAL_MS = 50 * 60 * 1000; // 50 minutes (before 1hr expiry)
@@ -43,6 +44,7 @@ export async function initAuth(apiUrl, token) {
43
44
  const auth = await fetchCredentials(apiUrl, token);
44
45
  currentCredentials = auth.credentials;
45
46
  currentConfig = auth.config;
47
+ currentPollerId = auth.pollerId;
46
48
  logger.info(`Authenticated successfully. Region: ${auth.config.region}`);
47
49
  logger.info(` SQS Queue: ${auth.config.sqsQueueUrl}`);
48
50
  logger.info(` Sessions Table: ${auth.config.sessionsTable}`);
@@ -75,6 +77,9 @@ export function getAuthConfig() {
75
77
  }
76
78
  return currentConfig;
77
79
  }
80
+ export function getPollerId() {
81
+ return currentPollerId;
82
+ }
78
83
  export function isTokenMode() {
79
84
  return currentCredentials !== null;
80
85
  }
@@ -5,6 +5,7 @@ import { WebClient } from '@slack/web-api';
5
5
  import { config } from './config.js';
6
6
  import { logger } from './logger.js';
7
7
  import { getBaseBrainPath } from './brain-manager.js';
8
+ import { getPollerId } from './auth-provider.js';
8
9
  /**
9
10
  * Maps tool names (or prefixes) to human-readable status messages.
10
11
  * More specific patterns are checked first.
@@ -136,6 +137,17 @@ function buildPrompt(msg, resumeHint) {
136
137
  if (msg.type === 'button_click' && msg.button) {
137
138
  prompt += `\n\n**Button Click:** User clicked button \`${msg.button.action_id}\` with value \`${msg.button.value}\``;
138
139
  }
140
+ if (msg.type === 'modal_submission' && msg.modal) {
141
+ prompt += `\n\n**Modal Submitted:** User filled out "${msg.modal.callbackId}"\n`;
142
+ if (msg.modal.values) {
143
+ for (const [key, value] of Object.entries(msg.modal.values)) {
144
+ prompt += `- ${key}: ${value}\n`;
145
+ }
146
+ }
147
+ }
148
+ if (msg.type === 'view_closed' && msg.modal) {
149
+ prompt += `\n\n**Modal Dismissed:** User closed "${msg.modal.callbackId}" without submitting.`;
150
+ }
139
151
  if (msg.teamvibe.emailChannelPrompt) {
140
152
  prompt += '\n\n**Channel Instructions:**\n' + msg.teamvibe.emailChannelPrompt + '\n';
141
153
  }
@@ -295,6 +307,8 @@ async function runClaudeCode(msg, sessionLog, cwd, sessionId, isFirstMessage = t
295
307
  TEAMVIBE_POLLER_TOKEN: config.TEAMVIBE_POLLER_TOKEN || '',
296
308
  TEAMVIBE_WORKSPACE_ID: msg.teamvibe.workspaceId,
297
309
  TEAMVIBE_CHANNEL_ID: msg.teamvibe.channelId,
310
+ TEAMVIBE_BOT_ID: msg.teamvibe.botId,
311
+ TEAMVIBE_POLLER_ID: getPollerId() || '',
298
312
  },
299
313
  stdio: ['pipe', 'pipe', 'pipe'],
300
314
  });
package/dist/config.js CHANGED
@@ -40,7 +40,7 @@ const configSchema = z.object({
40
40
  .transform((v) => v.toLowerCase() === 'true'),
41
41
  BRAIN_UPDATE_COOLDOWN_MS: z.coerce.number().default(300000), // 5 minutes
42
42
  // Maintenance heartbeat
43
- MAINTENANCE_INTERVAL_MS: z.coerce.number().default(86400000), // 24 hours between maintenance per brain
43
+ MAINTENANCE_INTERVAL_MS: z.coerce.number().default(21600000), // 6 hours between maintenance per brain
44
44
  MAINTENANCE_CHECK_INTERVAL_MS: z.coerce.number().default(300000), // 5 min check loop
45
45
  MAINTENANCE_ENABLED: z.string().default('true').transform((v) => v.toLowerCase() === 'true'),
46
46
  });
@@ -3,7 +3,7 @@ import type { TeamVibeQueueMessage } from './types.js';
3
3
  * Register a brain from a real message so we know about it for heartbeats.
4
4
  * Called from processMessage() after brain path is resolved.
5
5
  */
6
- export declare function registerBrain(msg: TeamVibeQueueMessage, brainDir?: string): void;
6
+ export declare function registerBrain(msg: TeamVibeQueueMessage): void;
7
7
  /**
8
8
  * Start the periodic heartbeat check loop.
9
9
  * Checks every MAINTENANCE_CHECK_INTERVAL_MS whether any brain needs maintenance.
@@ -1,5 +1,3 @@
1
- import { readFileSync, existsSync } from 'fs';
2
- import { join } from 'path';
3
1
  import { config } from './config.js';
4
2
  import { logger } from './logger.js';
5
3
  import { isAtCapacity } from './claude-spawner.js';
@@ -9,7 +7,7 @@ let heartbeatInterval = null;
9
7
  * Register a brain from a real message so we know about it for heartbeats.
10
8
  * Called from processMessage() after brain path is resolved.
11
9
  */
12
- export function registerBrain(msg, brainDir) {
10
+ export function registerBrain(msg) {
13
11
  const brain = msg.teamvibe.brain;
14
12
  if (!brain?.brainId)
15
13
  return;
@@ -27,30 +25,9 @@ export function registerBrain(msg, brainDir) {
27
25
  botToken: msg.teamvibe.botToken,
28
26
  channelId: msg.teamvibe.channelId,
29
27
  lastHeartbeat: existing?.lastHeartbeat ?? 0,
30
- brainDir: brainDir ?? existing?.brainDir,
31
28
  });
32
29
  logger.debug(`[Heartbeat] Registered brain: ${brain.brainId}`);
33
30
  }
34
- /**
35
- * Check if consolidation ran recently by reading memory/.last_consolidation.
36
- * Returns true if consolidation should be skipped (ran within last 24h).
37
- */
38
- function shouldSkipConsolidation(brainDir) {
39
- try {
40
- const filePath = join(brainDir, 'memory', '.last_consolidation');
41
- if (!existsSync(filePath))
42
- return false;
43
- const content = readFileSync(filePath, 'utf-8').trim();
44
- const lastDate = new Date(content);
45
- if (isNaN(lastDate.getTime()))
46
- return false;
47
- const elapsedMs = Date.now() - lastDate.getTime();
48
- return elapsedMs < 86_400_000; // 24 hours
49
- }
50
- catch {
51
- return false; // lenient: allow heartbeat on any error
52
- }
53
- }
54
31
  /**
55
32
  * Start the periodic heartbeat check loop.
56
33
  * Checks every MAINTENANCE_CHECK_INTERVAL_MS whether any brain needs maintenance.
@@ -68,12 +45,6 @@ export function startHeartbeatLoop(processMessageFn) {
68
45
  if (elapsed < config.MAINTENANCE_INTERVAL_MS) {
69
46
  continue;
70
47
  }
71
- // Skip if consolidation ran recently (code-enforced guard)
72
- if (info.brainDir && shouldSkipConsolidation(info.brainDir)) {
73
- logger.debug(`[Heartbeat] Skipping heartbeat for ${brainId} — last_consolidation < 24h`);
74
- info.lastHeartbeat = now;
75
- continue;
76
- }
77
48
  if (isAtCapacity()) {
78
49
  logger.debug(`[Heartbeat] At capacity, skipping heartbeat for ${brainId}`);
79
50
  continue;
@@ -30,15 +30,6 @@ export async function postMaintenanceReports(brainPath, channelId) {
30
30
  try {
31
31
  const content = await readFile(filePath, 'utf-8');
32
32
  const report = JSON.parse(content);
33
- // Skip no-op reports (consolidation ran but found nothing to do)
34
- if (report.operationCounts) {
35
- const { created, modified, deleted } = report.operationCounts;
36
- if (created === 0 && modified === 0 && deleted === 0) {
37
- logger.info(`[MaintenanceReporter] Skipping no-op report ${file} (0 changes)`);
38
- await unlink(filePath).catch(() => { });
39
- continue;
40
- }
41
- }
42
33
  if (!report.operationType) {
43
34
  logger.warn(`[MaintenanceReporter] Skipping ${file}: missing operationType`);
44
35
  continue;
package/dist/poller.js CHANGED
@@ -125,7 +125,7 @@ async function processMessage(received) {
125
125
  return;
126
126
  }
127
127
  // Register brain for heartbeat tracking
128
- registerBrain(queueMessage, kbPath);
128
+ registerBrain(queueMessage);
129
129
  // Try to acquire session lock
130
130
  let lockResult = await acquireSessionLock(threadId, kbPath);
131
131
  if (!lockResult.success) {
package/dist/types.d.ts CHANGED
@@ -26,7 +26,7 @@ export interface TeamVibeQueueMessage {
26
26
  inReplyTo?: string;
27
27
  };
28
28
  };
29
- type: 'message' | 'approval_response' | 'button_click';
29
+ type: 'message' | 'approval_response' | 'button_click' | 'modal_submission' | 'view_closed';
30
30
  approval?: {
31
31
  action_id: string;
32
32
  approved: boolean;
@@ -35,6 +35,11 @@ export interface TeamVibeQueueMessage {
35
35
  action_id: string;
36
36
  value: string;
37
37
  };
38
+ modal?: {
39
+ callbackId: string;
40
+ modalDefId: string;
41
+ values?: Record<string, string>;
42
+ };
38
43
  teamvibe: {
39
44
  workspaceId: string;
40
45
  botId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamvibe/poller",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {