@bike4mind/cli 0.2.19-feat-unified-agent-system.17813 → 0.2.20-add-confluence-comments.17883

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-D2RBSVLE.js";
4
+ } from "./chunk-MYFZJMSB.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;
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-GRCMDIFP.js";
5
+ } from "./chunk-JS7JT4EU.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -11,7 +11,7 @@ import {
11
11
  RealtimeVoiceUsageTransaction,
12
12
  TextGenerationUsageTransaction,
13
13
  TransferCreditTransaction
14
- } from "./chunk-D2RBSVLE.js";
14
+ } from "./chunk-MYFZJMSB.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
17
17
  import { z } from "zod";
@@ -13,7 +13,7 @@ import {
13
13
  dayjsConfig_default,
14
14
  extractSnippetMeta,
15
15
  settingsMap
16
- } from "./chunk-D2RBSVLE.js";
16
+ } from "./chunk-MYFZJMSB.js";
17
17
  import {
18
18
  Logger
19
19
  } from "./chunk-OCYRD7D6.js";
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-GRCMDIFP.js";
10
+ } from "./chunk-JS7JT4EU.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-D2RBSVLE.js";
14
+ } from "./chunk-MYFZJMSB.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -814,6 +814,13 @@ var RapidReplyFallbackBehaviors = ["disable", "continue", "notify"];
814
814
 
815
815
  // ../../b4m-core/packages/common/dist/src/types/entities/SystemSecretsTypes.js
816
816
  var SST_PLACEHOLDER_VALUE = "my-secret-placeholder-value";
817
+ var NOT_CONFIGURED_PLACEHOLDER = "not-configured";
818
+ function isPlaceholderValue(value) {
819
+ if (!value)
820
+ return true;
821
+ const normalized = value.trim().toLowerCase();
822
+ return normalized === SST_PLACEHOLDER_VALUE.toLowerCase() || normalized === NOT_CONFIGURED_PLACEHOLDER.toLowerCase();
823
+ }
817
824
  var SecretAuditEvents;
818
825
  (function(SecretAuditEvents2) {
819
826
  SecretAuditEvents2["SECRET_CREATED"] = "SECRET_CREATED";
@@ -4517,10 +4524,11 @@ function formatPageResponse(page, siteUrl) {
4517
4524
  link = `${baseUrl}/pages/${page.id}`;
4518
4525
  }
4519
4526
  return {
4520
- id: page.id,
4527
+ pageId: page.id,
4521
4528
  title: page.title,
4522
4529
  status: page.status,
4523
4530
  spaceId: page.spaceId,
4531
+ spaceKey: page.space?.key,
4524
4532
  body: stripHtmlAndNormalizeWhitespace(page.body?.storage?.value || page.body?.view?.value),
4525
4533
  version: page.version?.number,
4526
4534
  parentId: page.parentId,
@@ -4585,12 +4593,49 @@ function formatSpaceList(spacesResponse, siteUrl) {
4585
4593
  results
4586
4594
  };
4587
4595
  }
4596
+ function formatCommentResponse(comment, siteUrl) {
4597
+ if (!comment || typeof comment !== "object" || comment.error || comment.errors) {
4598
+ return comment;
4599
+ }
4600
+ const baseUrl = comment?._links?.base || siteUrl.replace(/\/$/, "");
4601
+ const link = comment._links?.webui ? `${baseUrl}${comment._links.webui}` : "";
4602
+ return {
4603
+ id: comment.id,
4604
+ type: comment.type,
4605
+ // 'comment'
4606
+ status: comment.status,
4607
+ title: comment.title,
4608
+ // Usually "Re: Page Title"
4609
+ body: stripHtmlAndNormalizeWhitespace(comment.body?.storage?.value || comment.body?.view?.value),
4610
+ author: comment.history?.createdBy ? formatUserResponse(comment.history.createdBy) : void 0,
4611
+ created: comment.history?.createdDate,
4612
+ updated: comment.history?.lastUpdated?.when,
4613
+ parentId: comment.container?.id,
4614
+ // Page ID
4615
+ parentCommentId: comment.ancestors?.length ? comment.ancestors[comment.ancestors.length - 1].id : void 0,
4616
+ link,
4617
+ inlineProperties: comment.extensions?.inlineProperties
4618
+ // For inline comments
4619
+ };
4620
+ }
4621
+ function formatCommentList(commentsResponse, siteUrl) {
4622
+ if (!commentsResponse || typeof commentsResponse !== "object" || commentsResponse.error || commentsResponse.errors) {
4623
+ return commentsResponse;
4624
+ }
4625
+ const results = Array.isArray(commentsResponse.results) ? commentsResponse.results.map((comment) => formatCommentResponse(comment, siteUrl)) : [];
4626
+ return {
4627
+ results,
4628
+ start: commentsResponse.start,
4629
+ limit: commentsResponse.limit,
4630
+ size: commentsResponse.size
4631
+ };
4632
+ }
4588
4633
  function formatPageList(pagesResponse, siteUrl) {
4589
4634
  if (!pagesResponse || typeof pagesResponse !== "object" || pagesResponse.error || pagesResponse.errors) {
4590
4635
  return pagesResponse;
4591
4636
  }
4592
4637
  const results = Array.isArray(pagesResponse.results) ? pagesResponse.results.map((page) => ({
4593
- id: page.id,
4638
+ pageId: page.id,
4594
4639
  title: page.title,
4595
4640
  status: page.status,
4596
4641
  parentId: page.parentId,
@@ -4638,6 +4683,10 @@ var ConfluenceApi = class {
4638
4683
  body: options.body ? JSON.stringify(options.body) : void 0
4639
4684
  });
4640
4685
  console.error(`Confluence API Response: ${response.status} ${response.statusText}`);
4686
+ const scopes = response.headers.get("X-OAuth-Scopes") || response.headers.get("x-oauth-scopes");
4687
+ if (scopes) {
4688
+ console.error(`[Debug] Current Token Scopes: ${scopes}`);
4689
+ }
4641
4690
  if (!response.ok) {
4642
4691
  const rawBody = await response.text();
4643
4692
  let errorDetail = response.statusText;
@@ -4927,6 +4976,168 @@ var ConfluenceApi = class {
4927
4976
  const result = await this.getV1("/user/current", { expand: "personalSpace" });
4928
4977
  return formatUserResponse(result);
4929
4978
  }
4979
+ /**
4980
+ * Get comments for a Confluence page (v1 API)
4981
+ */
4982
+ async getPageComments(params) {
4983
+ const { pageId, limit = 25, start = 0, expand } = params;
4984
+ if (!pageId) {
4985
+ throw new Error("pageId is required to fetch comments.");
4986
+ }
4987
+ const comments = await this.getV1(`/content/${pageId}/child/comment`, {
4988
+ limit: Math.min(Math.max(limit, 1), 50),
4989
+ start,
4990
+ expand: expand || "body.storage,history.lastUpdated,history.createdBy,ancestors,extensions.inlineProperties"
4991
+ });
4992
+ return formatCommentList(comments, this.config.siteUrl);
4993
+ }
4994
+ /**
4995
+ * Get a specific comment (v1 API)
4996
+ */
4997
+ async getComment(params) {
4998
+ const { commentId } = params;
4999
+ if (!commentId)
5000
+ throw new Error("commentId is required");
5001
+ const comment = await this.getV1(`/content/${commentId}`, {
5002
+ expand: "body.storage,history.lastUpdated,history.createdBy,ancestors,extensions.inlineProperties,container"
5003
+ });
5004
+ return formatCommentResponse(comment, this.config.siteUrl);
5005
+ }
5006
+ /**
5007
+ * Add a comment to a page (Uses v2 API for creation)
5008
+ */
5009
+ async addComment(params) {
5010
+ const { pageId, content, parentId, inlineOriginalSelection } = params;
5011
+ if (!pageId || !content) {
5012
+ throw new Error("pageId and content are required to add a comment.");
5013
+ }
5014
+ if (inlineOriginalSelection) {
5015
+ const payload = {
5016
+ pageId,
5017
+ body: {
5018
+ value: content,
5019
+ representation: "storage"
5020
+ },
5021
+ inlineProperties: {
5022
+ originalSelection: inlineOriginalSelection
5023
+ }
5024
+ };
5025
+ const result = await this.post("/inline-comments", payload);
5026
+ return formatCommentResponse(result, this.config.siteUrl);
5027
+ }
5028
+ const payloadA = {
5029
+ pageId,
5030
+ body: {
5031
+ value: content,
5032
+ representation: "storage"
5033
+ }
5034
+ };
5035
+ if (parentId) {
5036
+ payloadA.parentId = parentId;
5037
+ }
5038
+ const payloadB = {
5039
+ pageId,
5040
+ body: {
5041
+ storage: {
5042
+ value: content,
5043
+ representation: "storage"
5044
+ }
5045
+ }
5046
+ };
5047
+ if (parentId) {
5048
+ payloadB.parentId = parentId;
5049
+ }
5050
+ try {
5051
+ const result = await this.post("/footer-comments", payloadA);
5052
+ return formatCommentResponse(result, this.config.siteUrl);
5053
+ } catch (errorA) {
5054
+ console.warn(`Confluence v2 footer-comments (Structure A) failed: ${errorA.message}.`);
5055
+ try {
5056
+ const result = await this.post("/footer-comments", payloadB);
5057
+ return formatCommentResponse(result, this.config.siteUrl);
5058
+ } catch (errorB) {
5059
+ console.warn(`Confluence v2 footer-comments (Structure B) failed: ${errorB.message}. Attempting v1 fallback.`);
5060
+ if (errorA.message?.includes("403") || errorB.message?.includes("403")) {
5061
+ throw new Error(`Permission Denied (403). Check 'write:comment:confluence' scope.`);
5062
+ }
5063
+ }
5064
+ }
5065
+ try {
5066
+ const payload = {
5067
+ type: "comment",
5068
+ container: {
5069
+ id: pageId,
5070
+ type: "page"
5071
+ },
5072
+ body: {
5073
+ storage: {
5074
+ value: content,
5075
+ representation: "storage"
5076
+ }
5077
+ }
5078
+ };
5079
+ if (parentId) {
5080
+ payload.ancestors = [{ id: parentId }];
5081
+ }
5082
+ const result = await this.postV1("/content", payload);
5083
+ return formatCommentResponse(result, this.config.siteUrl);
5084
+ } catch (error) {
5085
+ if (error.message?.includes("410")) {
5086
+ throw new Error("Confluence API v1 is deprecated (410) and v2 does not yet fully support threaded replies. Please create a top-level comment instead.");
5087
+ }
5088
+ throw error;
5089
+ }
5090
+ }
5091
+ /**
5092
+ * Update a comment (v1 API)
5093
+ */
5094
+ async updateComment(params) {
5095
+ const { commentId, content, inlineOriginalSelection } = params;
5096
+ if (!commentId || !content) {
5097
+ throw new Error("commentId and content are required to update a comment.");
5098
+ }
5099
+ const currentComment = await this.getV1(`/content/${commentId}`, {
5100
+ expand: "version,body.storage"
5101
+ });
5102
+ const currentVersion = currentComment?.version?.number;
5103
+ if (typeof currentVersion !== "number") {
5104
+ throw new Error(`Unable to determine current version for comment ${commentId}.`);
5105
+ }
5106
+ const payload = {
5107
+ id: commentId,
5108
+ type: "comment",
5109
+ status: "current",
5110
+ title: currentComment.title,
5111
+ // Title usually persists for comments
5112
+ version: {
5113
+ number: currentVersion + 1
5114
+ },
5115
+ body: {
5116
+ storage: {
5117
+ value: content,
5118
+ representation: "storage"
5119
+ }
5120
+ }
5121
+ };
5122
+ if (inlineOriginalSelection) {
5123
+ payload.extensions = {
5124
+ inlineProperties: {
5125
+ originalSelection: inlineOriginalSelection
5126
+ }
5127
+ };
5128
+ }
5129
+ const result = await this.put(`/content/${commentId}`, payload);
5130
+ return formatCommentResponse(result, this.config.siteUrl);
5131
+ }
5132
+ /**
5133
+ * Delete a comment (v1 API)
5134
+ */
5135
+ async deleteComment(params) {
5136
+ const { commentId } = params;
5137
+ if (!commentId)
5138
+ throw new Error("commentId is required");
5139
+ await this.requestV1("DELETE", `/content/${commentId}`);
5140
+ }
4930
5141
  };
4931
5142
 
4932
5143
  // ../../b4m-core/packages/common/dist/src/jira/format.js
@@ -6266,6 +6477,8 @@ export {
6266
6477
  RapidReplyTransitionModes,
6267
6478
  RapidReplyFallbackBehaviors,
6268
6479
  SST_PLACEHOLDER_VALUE,
6480
+ NOT_CONFIGURED_PLACEHOLDER,
6481
+ isPlaceholderValue,
6269
6482
  SecretAuditEvents,
6270
6483
  SupportedFabFileMimeTypes,
6271
6484
  CODE_FILE_MIME_TYPES,
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-GRCMDIFP.js";
9
+ } from "./chunk-JS7JT4EU.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-D2RBSVLE.js";
14
+ } from "./chunk-MYFZJMSB.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-E4K7LPQC.js";
6
- import "./chunk-GRCMDIFP.js";
7
- import "./chunk-D2RBSVLE.js";
5
+ } from "./chunk-M2J5JZWW.js";
6
+ import "./chunk-JS7JT4EU.js";
7
+ import "./chunk-MYFZJMSB.js";
8
8
  import "./chunk-OCYRD7D6.js";
9
9
  export {
10
10
  createFabFile,