@bike4mind/cli 0.2.10-slack-metrics-admin-dashboard.17277 → 0.2.11-feat-api-key-rate-limiting.17321

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-6EQ62KRQ.js";
4
+ } from "./chunk-JS23EPWX.js";
5
5
  import "./chunk-PDX44BCA.js";
6
6
 
7
7
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
@@ -16,7 +16,7 @@ import {
16
16
  dayjsConfig_default,
17
17
  extractSnippetMeta,
18
18
  settingsMap
19
- } from "./chunk-6EQ62KRQ.js";
19
+ } from "./chunk-JS23EPWX.js";
20
20
 
21
21
  // ../../b4m-core/packages/utils/dist/src/storage/S3Storage.js
22
22
  import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3";
@@ -249,6 +249,17 @@ var AnthropicBackend = class {
249
249
  this._api = new Anthropic({ apiKey });
250
250
  this.logger = logger ?? new Logger();
251
251
  }
252
+ /**
253
+ * Get thinking blocks from the last assistant content.
254
+ * Filters to only include thinking/redacted_thinking blocks.
255
+ * Returns undefined if thinking is disabled or no blocks are present.
256
+ */
257
+ getThinkingBlocks() {
258
+ if (!this.isThinkingEnabled)
259
+ return void 0;
260
+ const blocks = this.lastAssistantContent.filter((block) => block?.type === "thinking" || block?.type === "redacted_thinking");
261
+ return blocks.length > 0 ? blocks : void 0;
262
+ }
252
263
  async getModelInfo() {
253
264
  return [
254
265
  {
@@ -701,8 +712,12 @@ var AnthropicBackend = class {
701
712
  this.logger.debug(`[Tool Execution] Last few messages:`, JSON.stringify(messages.slice(-3), null, 2));
702
713
  await this.complete(model, messages, options, cb, toolsUsed);
703
714
  } else {
704
- this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
705
- await cb([null], { toolsUsed });
715
+ const thinkingBlocks = this.getThinkingBlocks();
716
+ this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback with ${thinkingBlocks?.length || 0} thinking blocks`);
717
+ await cb([null], {
718
+ toolsUsed,
719
+ thinking: thinkingBlocks
720
+ });
706
721
  }
707
722
  return;
708
723
  }
@@ -774,8 +789,12 @@ var AnthropicBackend = class {
774
789
  await this.complete(model, messages, { ...options, tools: void 0, _internal: void 0 }, cb, toolsUsed);
775
790
  }
776
791
  } else {
777
- this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
778
- await cb([null], { toolsUsed });
792
+ const thinkingBlocks = this.getThinkingBlocks();
793
+ this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback with ${thinkingBlocks?.length || 0} thinking blocks`);
794
+ await cb([null], {
795
+ toolsUsed,
796
+ thinking: thinkingBlocks
797
+ });
779
798
  }
780
799
  return;
781
800
  }
@@ -672,6 +672,14 @@ var RealtimeVoiceUsageTransaction = BaseCreditTransaction.extend({
672
672
  model: z7.string(),
673
673
  sessionId: z7.string()
674
674
  });
675
+ var CompletionApiUsageTransaction = BaseCreditTransaction.extend({
676
+ type: z7.literal("completion_api_usage"),
677
+ model: z7.string(),
678
+ apiKeyId: z7.string().optional(),
679
+ // Optional - present for API key auth, undefined for JWT
680
+ inputTokens: z7.number(),
681
+ outputTokens: z7.number()
682
+ });
675
683
  var TransferCreditTransaction = BaseCreditTransaction.extend({
676
684
  type: z7.literal("transfer_credit"),
677
685
  recipientId: z7.string(),
@@ -686,6 +694,7 @@ var CreditTransaction = z7.discriminatedUnion("type", [
686
694
  ImageGenerationUsageTransaction,
687
695
  ImageEditUsageTransaction,
688
696
  RealtimeVoiceUsageTransaction,
697
+ CompletionApiUsageTransaction,
689
698
  TransferCreditTransaction,
690
699
  ReceivedCreditTransaction
691
700
  ]);
@@ -700,6 +709,7 @@ var CREDIT_DEDUCT_TRANSACTION_TYPES = [
700
709
  "image_generation_usage",
701
710
  "image_edit_usage",
702
711
  "realtime_voice_usage",
712
+ "completion_api_usage",
703
713
  "transfer_credit",
704
714
  "generic_deduct"
705
715
  ];
@@ -4047,13 +4057,6 @@ var SlackEvents;
4047
4057
  SlackEvents2["SLACK_COMMAND_COMPLETED"] = "Slack Command Completed";
4048
4058
  SlackEvents2["SLACK_MCP_TOOL_INVOKED"] = "Slack MCP Tool Invoked";
4049
4059
  SlackEvents2["SLACK_BULK_OPERATION"] = "Slack Bulk Operation Executed";
4050
- SlackEvents2["COMMAND_PROCESSED"] = "Slack Command Processed";
4051
- SlackEvents2["COMMAND_FAILED"] = "Slack Command Failed";
4052
- SlackEvents2["APP_CREATED"] = "Slack App Created";
4053
- SlackEvents2["WORKSPACE_DEACTIVATED"] = "Slack Workspace Deactivated";
4054
- SlackEvents2["CHANNEL_EXPORT_STARTED"] = "Slack Channel Export Started";
4055
- SlackEvents2["CHANNEL_EXPORT_COMPLETED"] = "Slack Channel Export Completed";
4056
- SlackEvents2["CHANNEL_EXPORT_FAILED"] = "Slack Channel Export Failed";
4057
4060
  })(SlackEvents || (SlackEvents = {}));
4058
4061
 
4059
4062
  // ../../b4m-core/packages/common/dist/src/schemas/team.js
@@ -5908,6 +5911,9 @@ function buildSSEEvent(text, info) {
5908
5911
  outputTokens: info.outputTokens
5909
5912
  };
5910
5913
  }
5914
+ if (info?.thinking && info.thinking.length > 0) {
5915
+ event.thinking = info.thinking;
5916
+ }
5911
5917
  return event;
5912
5918
  }
5913
5919
  function formatSSEError(error) {
@@ -6005,6 +6011,7 @@ export {
6005
6011
  ImageGenerationUsageTransaction,
6006
6012
  ImageEditUsageTransaction,
6007
6013
  RealtimeVoiceUsageTransaction,
6014
+ CompletionApiUsageTransaction,
6008
6015
  TransferCreditTransaction,
6009
6016
  CreditTransaction,
6010
6017
  CREDIT_ADD_TRANSACTION_TYPES,
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-23GLLYOT.js";
10
+ } from "./chunk-4RN2B56U.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-6EQ62KRQ.js";
14
+ } from "./chunk-JS23EPWX.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-23GLLYOT.js";
9
+ } from "./chunk-4RN2B56U.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-6EQ62KRQ.js";
14
+ } from "./chunk-JS23EPWX.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -2,15 +2,16 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-23GLLYOT.js";
5
+ } from "./chunk-4RN2B56U.js";
6
6
  import {
7
+ CompletionApiUsageTransaction,
7
8
  GenericCreditDeductTransaction,
8
9
  ImageEditUsageTransaction,
9
10
  ImageGenerationUsageTransaction,
10
11
  RealtimeVoiceUsageTransaction,
11
12
  TextGenerationUsageTransaction,
12
13
  TransferCreditTransaction
13
- } from "./chunk-6EQ62KRQ.js";
14
+ } from "./chunk-JS23EPWX.js";
14
15
 
15
16
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
16
17
  import { z } from "zod";
@@ -20,6 +21,7 @@ var SubtractCreditsSchema = z.discriminatedUnion("type", [
20
21
  ImageGenerationUsageTransaction.omit({ createdAt: true, updatedAt: true }),
21
22
  RealtimeVoiceUsageTransaction.omit({ createdAt: true, updatedAt: true }),
22
23
  ImageEditUsageTransaction.omit({ createdAt: true, updatedAt: true }),
24
+ CompletionApiUsageTransaction.omit({ createdAt: true, updatedAt: true }),
23
25
  TransferCreditTransaction.omit({ createdAt: true, updatedAt: true })
24
26
  ]);
25
27
  async function subtractCredits(parameters, { db, creditHolderMethods, skipBalanceUpdate, currentCreditHolder }) {
@@ -63,6 +65,20 @@ async function subtractCredits(parameters, { db, creditHolderMethods, skipBalanc
63
65
  inputTokens: params.inputTokens,
64
66
  outputTokens: params.outputTokens
65
67
  });
68
+ } else if (type === "completion_api_usage") {
69
+ await db.creditTransactions.createTransaction("completion_api_usage", {
70
+ ownerId,
71
+ ownerType,
72
+ credits: -Math.abs(credits),
73
+ // Negative for usage
74
+ description: description || "Completion API usage",
75
+ metadata,
76
+ model: params.model,
77
+ apiKeyId: params.apiKeyId,
78
+ // Optional - present for API key auth, undefined for JWT
79
+ inputTokens: params.inputTokens,
80
+ outputTokens: params.outputTokens
81
+ });
66
82
  } else if (type === "image_generation_usage") {
67
83
  await db.creditTransactions.createTransaction("image_generation_usage", {
68
84
  ownerId,
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-E2VXQGEM.js";
6
- import "./chunk-23GLLYOT.js";
5
+ } from "./chunk-OX6W5SJ7.js";
6
+ import "./chunk-4RN2B56U.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
- import "./chunk-6EQ62KRQ.js";
8
+ import "./chunk-JS23EPWX.js";
9
9
  import "./chunk-PDX44BCA.js";
10
10
  export {
11
11
  createFabFile,