@bike4mind/cli 0.2.38-feat-context-telemetry.20185 → 0.2.38-fix-delegate-agent-timeout.20158

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-7Q7X535R.js";
4
+ } from "./chunk-OCFOJXLA.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
7
7
  var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-QP64APFV.js";
10
+ } from "./chunk-QCDYXXSD.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-7Q7X535R.js";
14
+ } from "./chunk-OCFOJXLA.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -4,7 +4,7 @@ import {
4
4
  getOpenWeatherKey,
5
5
  getSerperKey,
6
6
  getWolframAlphaKey
7
- } from "./chunk-7DDFUFLD.js";
7
+ } from "./chunk-J3YSVA6W.js";
8
8
  import {
9
9
  BFLImageService,
10
10
  BaseStorage,
@@ -16,16 +16,15 @@ import {
16
16
  OpenAIBackend,
17
17
  OpenAIImageService,
18
18
  XAIImageService
19
- } from "./chunk-QP64APFV.js";
19
+ } from "./chunk-QCDYXXSD.js";
20
20
  import {
21
21
  Logger
22
22
  } from "./chunk-PFBYGCOW.js";
23
23
  import {
24
24
  ConfigStore,
25
25
  logger
26
- } from "./chunk-BL2FWRZZ.js";
26
+ } from "./chunk-HJVFUXVX.js";
27
27
  import {
28
- ALERT_THRESHOLDS,
29
28
  AiEvents,
30
29
  ApiKeyEvents,
31
30
  ApiKeyScope,
@@ -80,9 +79,8 @@ import {
80
79
  b4mLLMTools,
81
80
  getMcpProviderMetadata,
82
81
  getViewById,
83
- resolveNavigationIntents,
84
- sanitizeTelemetryError
85
- } from "./chunk-7Q7X535R.js";
82
+ resolveNavigationIntents
83
+ } from "./chunk-OCFOJXLA.js";
86
84
 
87
85
  // src/utils/fileSearch.ts
88
86
  import * as fs from "fs";
@@ -13326,7 +13324,14 @@ var generateMcpToolsFromCache = (serverName, cachedTools, callTool) => {
13326
13324
  };
13327
13325
 
13328
13326
  // ../../b4m-core/packages/services/dist/src/llm/agents/ServerSubagentOrchestrator.js
13329
- var SUBAGENT_TIMEOUT_MS = 5 * 60 * 1e3;
13327
+ var SUBAGENT_TIMEOUT_BY_THOROUGHNESS = {
13328
+ quick: 2 * 60 * 1e3,
13329
+ // 2 minutes
13330
+ medium: 5 * 60 * 1e3,
13331
+ // 5 minutes
13332
+ very_thorough: 10 * 60 * 1e3
13333
+ // 10 minutes
13334
+ };
13330
13335
 
13331
13336
  // ../../b4m-core/packages/services/dist/src/llm/agents/CodeReviewAgent.js
13332
13337
  var CodeReviewAgent = (config) => ({
@@ -13484,6 +13489,11 @@ You MUST use the selected_repositories list to automatically resolve the owner a
13484
13489
  - List and manage GitHub notifications
13485
13490
  - Mark notifications as read/done
13486
13491
 
13492
+ ## Performance Tips
13493
+ 1. **Use \`search_pull_requests\` for date-filtered queries**: When asked for PRs within a date range (e.g., "PRs closed in the last 7 days"), use \`search_pull_requests\` with the \`since\` parameter instead of paginating through \`list_pull_requests\`. This returns filtered results in a single call.
13494
+ 2. **Always use per_page: 100**: When listing PRs, issues, or any paginated endpoint, always set \`per_page: 100\` to minimize the number of API calls needed.
13495
+ 3. **Avoid fetching individual PR details unless necessary**: The list/search endpoints include title, state, labels, dates, and branch info. Only call \`get_pull_request\` if you need body, mergeable status, or review details.
13496
+
13487
13497
  ## Best Practices
13488
13498
  1. When searching issues or PRs, use GitHub search syntax (e.g., \`is:open label:bug assignee:username\`)
13489
13499
  2. When creating PRs, always include a clear title and description
@@ -14081,358 +14091,6 @@ var CombinedExtractor = class {
14081
14091
  };
14082
14092
  var combinedExtractor = new CombinedExtractor();
14083
14093
 
14084
- // ../../b4m-core/packages/services/dist/src/telemetry/AnomalyAlertService.js
14085
- var AnomalyAlertService = class _AnomalyAlertService {
14086
- constructor(loggerOrConfig, alertConfig) {
14087
- this.dedupCache = /* @__PURE__ */ new Map();
14088
- if (typeof loggerOrConfig.logger !== "undefined") {
14089
- const config = loggerOrConfig;
14090
- this.logger = config.logger;
14091
- this.config = config.alertConfig;
14092
- this.cacheRepository = config.cacheRepository;
14093
- } else {
14094
- this.logger = loggerOrConfig;
14095
- this.config = alertConfig;
14096
- }
14097
- }
14098
- /**
14099
- * Check if an alert should be sent and send it if appropriate
14100
- */
14101
- async checkAndAlert(telemetry) {
14102
- if (!this.config.enabled || !this.config.slackWebhookUrl) {
14103
- return false;
14104
- }
14105
- const { anomalies } = telemetry;
14106
- const threshold = this.config.alertThreshold ?? ALERT_THRESHOLDS.warning;
14107
- if (anomalies.anomalyScore < threshold) {
14108
- return false;
14109
- }
14110
- const isDup = await this.checkDeduplication(anomalies.dedupKey);
14111
- if (isDup) {
14112
- this.logger.info(`\u{1F4CA} [AnomalyAlert] Suppressed duplicate alert: ${anomalies.dedupKey}`);
14113
- return false;
14114
- }
14115
- try {
14116
- const message = this.formatSlackMessage(telemetry);
14117
- await this.sendSlackAlert(message);
14118
- this.logger.info(`\u{1F4CA} [AnomalyAlert] Alert sent for ${anomalies.primaryAnomaly} (score: ${anomalies.anomalyScore})`);
14119
- return true;
14120
- } catch (error) {
14121
- this.logger.error(`\u{1F4CA} [AnomalyAlert] Failed to send alert:`, error);
14122
- return false;
14123
- }
14124
- }
14125
- /**
14126
- * Check deduplication and claim the key atomically.
14127
- * Uses distributed MongoDB cache when available, falls back to in-memory.
14128
- *
14129
- * @returns true if this is a duplicate (should not send alert), false if we can proceed
14130
- */
14131
- async checkDeduplication(dedupKey) {
14132
- const windowMs = (this.config.dedupWindowMinutes ?? 5) * 60 * 1e3;
14133
- const cacheKey = `${_AnomalyAlertService.DEDUP_KEY_PREFIX}${dedupKey}`;
14134
- if (this.cacheRepository) {
14135
- try {
14136
- const result = await this.cacheRepository.claimDedup(cacheKey, { dedupKey, claimedAt: Date.now(), count: 1 }, windowMs);
14137
- return !result.claimed;
14138
- } catch (error) {
14139
- this.logger.warn(`\u{1F4CA} [AnomalyAlert] Distributed dedup failed, using in-memory:`, error);
14140
- }
14141
- }
14142
- return this.checkInMemoryDedup(dedupKey, windowMs);
14143
- }
14144
- /**
14145
- * In-memory deduplication check and record (fallback)
14146
- */
14147
- checkInMemoryDedup(dedupKey, windowMs) {
14148
- const entry = this.dedupCache.get(dedupKey);
14149
- if (entry) {
14150
- const timeSinceLastAlert = Date.now() - entry.lastAlertTime;
14151
- if (timeSinceLastAlert < windowMs) {
14152
- return true;
14153
- }
14154
- }
14155
- this.recordInMemoryAlert(dedupKey);
14156
- return false;
14157
- }
14158
- /**
14159
- * Record an alert in the in-memory cache
14160
- */
14161
- recordInMemoryAlert(dedupKey) {
14162
- const existing = this.dedupCache.get(dedupKey);
14163
- this.dedupCache.set(dedupKey, {
14164
- dedupKey,
14165
- lastAlertTime: Date.now(),
14166
- count: (existing?.count ?? 0) + 1
14167
- });
14168
- const oneHourAgo = Date.now() - 60 * 60 * 1e3;
14169
- for (const [key, entry] of this.dedupCache.entries()) {
14170
- if (entry.lastAlertTime < oneHourAgo) {
14171
- this.dedupCache.delete(key);
14172
- }
14173
- }
14174
- if (this.dedupCache.size > _AnomalyAlertService.MAX_CACHE_ENTRIES) {
14175
- const entries = Array.from(this.dedupCache.entries()).sort((a, b) => a[1].lastAlertTime - b[1].lastAlertTime);
14176
- const toRemove = entries.slice(0, this.dedupCache.size - _AnomalyAlertService.MAX_CACHE_ENTRIES);
14177
- for (const [key] of toRemove) {
14178
- this.dedupCache.delete(key);
14179
- }
14180
- }
14181
- }
14182
- /**
14183
- * Format telemetry into a Slack Block Kit message
14184
- */
14185
- formatSlackMessage(telemetry) {
14186
- const { anomalies, model, contextWindow, performance: performance2, tools, subagents } = telemetry;
14187
- const isCritical = anomalies.anomalyScore >= (this.config.criticalThreshold ?? ALERT_THRESHOLDS.critical);
14188
- const emoji = this.getSeverityEmoji(anomalies.severity);
14189
- const severityText = anomalies.severity.toUpperCase();
14190
- const title = `${emoji} Context Telemetry Alert: ${this.formatAnomalyType(anomalies.primaryAnomaly)}`;
14191
- const summaryText = `${severityText} anomaly detected (score: ${anomalies.anomalyScore}) - ${anomalies.primaryAnomaly}`;
14192
- const blocks = [
14193
- // Header
14194
- {
14195
- type: "header",
14196
- text: {
14197
- type: "plain_text",
14198
- text: title,
14199
- emoji: true
14200
- }
14201
- },
14202
- // Severity and score
14203
- {
14204
- type: "section",
14205
- fields: [
14206
- {
14207
- type: "mrkdwn",
14208
- text: `*Severity:*
14209
- ${emoji} ${severityText}`
14210
- },
14211
- {
14212
- type: "mrkdwn",
14213
- text: `*Anomaly Score:*
14214
- ${anomalies.anomalyScore}/100`
14215
- },
14216
- {
14217
- type: "mrkdwn",
14218
- text: `*Model:*
14219
- ${model.modelId}`
14220
- },
14221
- {
14222
- type: "mrkdwn",
14223
- text: `*Provider:*
14224
- ${model.provider}`
14225
- }
14226
- ]
14227
- },
14228
- // Divider
14229
- { type: "divider" }
14230
- ];
14231
- const anomalyDetails = this.buildAnomalyDetails(anomalies);
14232
- if (anomalyDetails.length > 0) {
14233
- blocks.push({
14234
- type: "section",
14235
- text: {
14236
- type: "mrkdwn",
14237
- text: `*Detected Anomalies:*
14238
- ${anomalyDetails.join("\n")}`
14239
- }
14240
- });
14241
- }
14242
- blocks.push({
14243
- type: "section",
14244
- fields: [
14245
- {
14246
- type: "mrkdwn",
14247
- text: `*Input Tokens:*
14248
- ${contextWindow.inputTokens.toLocaleString()}`
14249
- },
14250
- {
14251
- type: "mrkdwn",
14252
- text: `*Utilization:*
14253
- ${contextWindow.utilizationPercentage.toFixed(1)}%`
14254
- },
14255
- {
14256
- type: "mrkdwn",
14257
- text: `*Response Time:*
14258
- ${performance2.totalResponseTimeMs.toLocaleString()}ms`
14259
- },
14260
- {
14261
- type: "mrkdwn",
14262
- text: `*First Token:*
14263
- ${performance2.firstTokenTimeMs?.toLocaleString() ?? "N/A"}ms`
14264
- }
14265
- ]
14266
- });
14267
- const failedTools = tools?.filter((t) => t.failureCount > 0) ?? [];
14268
- if (failedTools.length > 0) {
14269
- const toolDetails = failedTools.map((t) => `\u2022 \`${t.toolName}\`: ${t.failureCount} failures${t.lastError ? ` - ${sanitizeTelemetryError(t.lastError, 50)}` : ""}`).join("\n");
14270
- blocks.push({
14271
- type: "section",
14272
- text: {
14273
- type: "mrkdwn",
14274
- text: `*Tool Failures:*
14275
- ${toolDetails}`
14276
- }
14277
- });
14278
- }
14279
- const timedOutAgents = subagents?.filter((s) => s.timeoutCount > 0) ?? [];
14280
- if (timedOutAgents.length > 0) {
14281
- const agentDetails = timedOutAgents.map((s) => `\u2022 \`${s.agentName}\`: ${s.timeoutCount} timeouts, ${s.totalDurationMs.toLocaleString()}ms total`).join("\n");
14282
- blocks.push({
14283
- type: "section",
14284
- text: {
14285
- type: "mrkdwn",
14286
- text: `*Subagent Timeouts:*
14287
- ${agentDetails}`
14288
- }
14289
- });
14290
- }
14291
- if (model.fallbackUsed) {
14292
- blocks.push({
14293
- type: "section",
14294
- text: {
14295
- type: "mrkdwn",
14296
- text: `*Fallback Used:*
14297
- ${model.originalModelId} \u2192 ${model.modelId}
14298
- Reason: ${model.fallbackReason ?? "Unknown"}`
14299
- }
14300
- });
14301
- }
14302
- blocks.push({ type: "divider" }, {
14303
- type: "context",
14304
- elements: [
14305
- {
14306
- type: "mrkdwn",
14307
- text: `Timestamp: ${telemetry.timestamp} | Dedup Key: \`${anomalies.dedupKey}\``
14308
- }
14309
- ]
14310
- });
14311
- if (isCritical) {
14312
- blocks.splice(1, 0, {
14313
- type: "section",
14314
- text: {
14315
- type: "mrkdwn",
14316
- text: "<!here> Critical anomaly requires attention!"
14317
- }
14318
- });
14319
- }
14320
- return {
14321
- text: summaryText,
14322
- blocks
14323
- };
14324
- }
14325
- /**
14326
- * Build list of detected anomaly details
14327
- */
14328
- buildAnomalyDetails(anomalies) {
14329
- const details = [];
14330
- if (anomalies.contextOverflow) {
14331
- details.push("\u{1F6A8} Context window overflow detected");
14332
- }
14333
- if (anomalies.criticalUtilization) {
14334
- details.push("\u26A0\uFE0F Critical context utilization (\u226595%)");
14335
- } else if (anomalies.highUtilization) {
14336
- details.push("\u26A0\uFE0F High context utilization (\u226590%)");
14337
- }
14338
- if (anomalies.criticalTruncation) {
14339
- details.push("\u26A0\uFE0F Critical message truncation (\u226575%)");
14340
- } else if (anomalies.highTruncation) {
14341
- details.push("\u26A0\uFE0F High message truncation (\u226550%)");
14342
- }
14343
- if (anomalies.toolFailureSpike) {
14344
- details.push("\u{1F527} Tool failure spike (\u22653 failures)");
14345
- }
14346
- if (anomalies.toolTimeout) {
14347
- details.push("\u23F1\uFE0F Tool timeout detected (>30s)");
14348
- }
14349
- if (anomalies.subagentTimeout) {
14350
- details.push("\u{1F916} Subagent timeout detected (>5min)");
14351
- }
14352
- if (anomalies.slowTotalResponse) {
14353
- details.push("\u{1F40C} Slow total response time (>60s)");
14354
- }
14355
- if (anomalies.slowFirstToken) {
14356
- details.push("\u{1F40C} Slow first token time (>10s)");
14357
- }
14358
- return details;
14359
- }
14360
- /**
14361
- * Get emoji for severity level
14362
- */
14363
- getSeverityEmoji(severity) {
14364
- switch (severity) {
14365
- case "critical":
14366
- return "\u{1F534}";
14367
- case "high":
14368
- return "\u{1F7E0}";
14369
- case "medium":
14370
- return "\u{1F7E1}";
14371
- case "low":
14372
- return "\u{1F7E2}";
14373
- default:
14374
- return "\u26AA";
14375
- }
14376
- }
14377
- /**
14378
- * Format anomaly type for display
14379
- */
14380
- formatAnomalyType(type) {
14381
- switch (type) {
14382
- case "context_overflow":
14383
- return "Context Overflow";
14384
- case "high_truncation":
14385
- return "High Truncation";
14386
- case "tool_failure":
14387
- return "Tool Failure";
14388
- case "subagent_timeout":
14389
- return "Subagent Timeout";
14390
- case "slow_response":
14391
- return "Slow Response";
14392
- case "multiple":
14393
- return "Multiple Anomalies";
14394
- case "none":
14395
- return "Unknown";
14396
- default:
14397
- return type;
14398
- }
14399
- }
14400
- /**
14401
- * Send the formatted message to Slack webhook
14402
- */
14403
- async sendSlackAlert(message) {
14404
- if (!this.config.slackWebhookUrl) {
14405
- throw new Error("Slack webhook URL not configured");
14406
- }
14407
- const response = await fetch(this.config.slackWebhookUrl, {
14408
- method: "POST",
14409
- headers: {
14410
- "Content-Type": "application/json"
14411
- },
14412
- body: JSON.stringify(message)
14413
- });
14414
- if (!response.ok) {
14415
- const errorText = await response.text();
14416
- const sanitizedError = errorText.slice(0, 100).replace(/https?:\/\/[^\s]+/g, "[URL_REDACTED]");
14417
- throw new Error(`Slack API error: ${response.status} - ${sanitizedError}`);
14418
- }
14419
- }
14420
- /**
14421
- * Get deduplication statistics for monitoring
14422
- */
14423
- getDedupStats() {
14424
- const fiveMinutesAgo = Date.now() - 5 * 60 * 1e3;
14425
- const recentAlerts = Array.from(this.dedupCache.values()).filter((e) => e.lastAlertTime >= fiveMinutesAgo).length;
14426
- return {
14427
- totalEntries: this.dedupCache.size,
14428
- recentAlerts,
14429
- distributedDedupEnabled: !!this.cacheRepository
14430
- };
14431
- }
14432
- };
14433
- AnomalyAlertService.MAX_CACHE_ENTRIES = 1e3;
14434
- AnomalyAlertService.DEDUP_KEY_PREFIX = "anomaly-alert-dedup:";
14435
-
14436
14094
  // ../../b4m-core/packages/services/dist/src/llm/ChatCompletionProcess.js
14437
14095
  var DISABLE_SERVER_THROTTLING = process.env.DISABLE_SERVER_THROTTLING === "true";
14438
14096
  var questSaveMutex = new Mutex();
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-QP64APFV.js";
5
+ } from "./chunk-QCDYXXSD.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -13,7 +13,7 @@ import {
13
13
  ToolUsageTransaction,
14
14
  TransferCreditTransaction,
15
15
  VideoGenerationUsageTransaction
16
- } from "./chunk-7Q7X535R.js";
16
+ } from "./chunk-OCFOJXLA.js";
17
17
 
18
18
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
19
19
  import { z } from "zod";
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@bike4mind/cli",
6
- version: "0.2.38-feat-context-telemetry.20185+28a1dc4b6",
6
+ version: "0.2.38-fix-delegate-agent-timeout.20158+00f896f19",
7
7
  type: "module",
8
8
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
9
9
  license: "UNLICENSED",
@@ -117,10 +117,10 @@ var package_default = {
117
117
  },
118
118
  devDependencies: {
119
119
  "@bike4mind/agents": "0.1.0",
120
- "@bike4mind/common": "2.58.1-feat-context-telemetry.20185+28a1dc4b6",
121
- "@bike4mind/mcp": "1.32.6-feat-context-telemetry.20185+28a1dc4b6",
122
- "@bike4mind/services": "2.54.2-feat-context-telemetry.20185+28a1dc4b6",
123
- "@bike4mind/utils": "2.11.1-feat-context-telemetry.20185+28a1dc4b6",
120
+ "@bike4mind/common": "2.58.1-fix-delegate-agent-timeout.20158+00f896f19",
121
+ "@bike4mind/mcp": "1.32.6-fix-delegate-agent-timeout.20158+00f896f19",
122
+ "@bike4mind/services": "2.54.2-fix-delegate-agent-timeout.20158+00f896f19",
123
+ "@bike4mind/utils": "2.11.1-fix-delegate-agent-timeout.20158+00f896f19",
124
124
  "@types/better-sqlite3": "^7.6.13",
125
125
  "@types/diff": "^5.0.9",
126
126
  "@types/jsonwebtoken": "^9.0.4",
@@ -138,7 +138,7 @@ var package_default = {
138
138
  optionalDependencies: {
139
139
  "@vscode/ripgrep": "^1.17.0"
140
140
  },
141
- gitHead: "28a1dc4b6001eb8a1c7328b0c4dea20e69990a01"
141
+ gitHead: "00f896f19866ccb5d005191fc2728f8fe849bd93"
142
142
  };
143
143
 
144
144
  // src/utils/updateChecker.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ChatModels
4
- } from "./chunk-7Q7X535R.js";
4
+ } from "./chunk-OCFOJXLA.js";
5
5
  import {
6
6
  DEFAULT_SANDBOX_CONFIG
7
7
  } from "./chunk-4BIBE3J7.js";
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-QP64APFV.js";
9
+ } from "./chunk-QCDYXXSD.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-7Q7X535R.js";
14
+ } from "./chunk-OCFOJXLA.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";