byterover-cli 2.5.1 → 2.6.0

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.
Files changed (85) hide show
  1. package/.env.production +7 -0
  2. package/LICENSE +44 -0
  3. package/bin/dev.js +8 -1
  4. package/bin/run.js +8 -1
  5. package/dist/server/config/environment.d.ts +0 -19
  6. package/dist/server/config/environment.js +29 -38
  7. package/dist/server/constants.d.ts +0 -9
  8. package/dist/server/constants.js +0 -12
  9. package/dist/server/core/domain/errors/auth-error.d.ts +0 -6
  10. package/dist/server/core/domain/errors/auth-error.js +0 -12
  11. package/dist/server/core/domain/errors/task-error.d.ts +0 -3
  12. package/dist/server/core/domain/errors/task-error.js +0 -8
  13. package/dist/server/core/domain/errors/transport-error.d.ts +0 -31
  14. package/dist/server/core/domain/errors/transport-error.js +0 -50
  15. package/dist/server/infra/connectors/rules/rules-connector-config.d.ts +0 -4
  16. package/dist/server/infra/http/models-dev-client.d.ts +0 -4
  17. package/dist/server/infra/http/models-dev-client.js +0 -6
  18. package/dist/server/infra/http/openrouter-api-client.d.ts +0 -8
  19. package/dist/server/infra/http/openrouter-api-client.js +0 -13
  20. package/dist/server/infra/http/provider-model-fetcher-registry.d.ts +0 -5
  21. package/dist/server/infra/http/provider-model-fetcher-registry.js +0 -7
  22. package/dist/server/infra/provider/env-provider-detector.d.ts +0 -20
  23. package/dist/server/infra/provider/env-provider-detector.js +0 -27
  24. package/dist/server/infra/storage/file-provider-config-store.d.ts +0 -4
  25. package/dist/server/infra/storage/file-provider-config-store.js +0 -6
  26. package/dist/server/utils/file-content-reader.d.ts +2 -1
  27. package/dist/server/utils/file-helpers.d.ts +0 -24
  28. package/dist/server/utils/file-helpers.js +0 -81
  29. package/dist/server/utils/process-logger.d.ts +0 -13
  30. package/dist/server/utils/process-logger.js +1 -78
  31. package/node_modules/@campfirein/brv-transport-client/LICENSE +95 -0
  32. package/node_modules/@campfirein/brv-transport-client/README.md +3 -4
  33. package/node_modules/@campfirein/brv-transport-client/package.json +2 -2
  34. package/oclif.manifest.json +1 -1
  35. package/package.json +6 -4
  36. package/dist/server/core/domain/entities/bullet.d.ts +0 -51
  37. package/dist/server/core/domain/entities/bullet.js +0 -94
  38. package/dist/server/core/domain/entities/memory.d.ts +0 -55
  39. package/dist/server/core/domain/entities/memory.js +0 -90
  40. package/dist/server/core/domain/entities/playbook.d.ts +0 -80
  41. package/dist/server/core/domain/entities/playbook.js +0 -214
  42. package/dist/server/core/domain/entities/presigned-url.d.ts +0 -9
  43. package/dist/server/core/domain/entities/presigned-url.js +0 -18
  44. package/dist/server/core/domain/entities/presigned-urls-response.d.ts +0 -10
  45. package/dist/server/core/domain/entities/presigned-urls-response.js +0 -18
  46. package/dist/server/core/domain/entities/retrieve-result.d.ts +0 -35
  47. package/dist/server/core/domain/entities/retrieve-result.js +0 -35
  48. package/dist/server/core/domain/errors/headless-prompt-error.d.ts +0 -11
  49. package/dist/server/core/domain/errors/headless-prompt-error.js +0 -18
  50. package/dist/server/core/interfaces/services/i-legacy-rule-detector.d.ts +0 -56
  51. package/dist/server/core/interfaces/services/i-legacy-rule-detector.js +0 -1
  52. package/dist/server/core/interfaces/services/i-memory-retrieval-service.d.ts +0 -39
  53. package/dist/server/core/interfaces/services/i-memory-retrieval-service.js +0 -1
  54. package/dist/server/core/interfaces/services/i-memory-storage-service.d.ts +0 -53
  55. package/dist/server/core/interfaces/services/i-memory-storage-service.js +0 -1
  56. package/dist/server/core/interfaces/services/i-terminal.d.ts +0 -146
  57. package/dist/server/core/interfaces/services/i-terminal.js +0 -1
  58. package/dist/server/core/interfaces/services/i-workspace-detector-service.d.ts +0 -8
  59. package/dist/server/core/interfaces/services/i-workspace-detector-service.js +0 -1
  60. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.d.ts +0 -20
  61. package/dist/server/core/interfaces/storage/i-onboarding-preference-store.js +0 -1
  62. package/dist/server/infra/connectors/rules/legacy-rule-detector.d.ts +0 -21
  63. package/dist/server/infra/connectors/rules/legacy-rule-detector.js +0 -106
  64. package/dist/server/infra/memory/http-memory-retrieval-service.d.ts +0 -18
  65. package/dist/server/infra/memory/http-memory-retrieval-service.js +0 -64
  66. package/dist/server/infra/memory/http-memory-storage-service.d.ts +0 -18
  67. package/dist/server/infra/memory/http-memory-storage-service.js +0 -72
  68. package/dist/server/infra/memory/memory-to-playbook-mapper.d.ts +0 -33
  69. package/dist/server/infra/memory/memory-to-playbook-mapper.js +0 -51
  70. package/dist/server/infra/storage/file-onboarding-preference-store.d.ts +0 -10
  71. package/dist/server/infra/storage/file-onboarding-preference-store.js +0 -45
  72. package/dist/server/infra/terminal/headless-terminal.d.ts +0 -91
  73. package/dist/server/infra/terminal/headless-terminal.js +0 -211
  74. package/dist/server/infra/workspace/workspace-detector-service.d.ts +0 -57
  75. package/dist/server/infra/workspace/workspace-detector-service.js +0 -165
  76. package/dist/server/utils/crash-log.d.ts +0 -14
  77. package/dist/server/utils/crash-log.js +0 -19
  78. package/dist/server/utils/emoji-helpers.d.ts +0 -38
  79. package/dist/server/utils/emoji-helpers.js +0 -42
  80. package/dist/server/utils/error-handler.d.ts +0 -51
  81. package/dist/server/utils/error-handler.js +0 -169
  82. package/dist/server/utils/oclif-error-helpers.d.ts +0 -40
  83. package/dist/server/utils/oclif-error-helpers.js +0 -46
  84. package/dist/server/utils/tool-display-formatter.d.ts +0 -53
  85. package/dist/server/utils/tool-display-formatter.js +0 -257
@@ -1,53 +0,0 @@
1
- import type { PresignedUrlsResponse } from '../../domain/entities/presigned-urls-response.js';
2
- /**
3
- * Parameters for requesting presigned URLs.
4
- */
5
- export type GetPresignedUrlsParams = {
6
- branch: string;
7
- fileNames: string[];
8
- sessionKey: string;
9
- spaceId: string;
10
- teamId: string;
11
- };
12
- /**
13
- * Parameters for confirming upload completion.
14
- */
15
- export type ConfirmUploadParams = {
16
- requestId: string;
17
- sessionKey: string;
18
- spaceId: string;
19
- teamId: string;
20
- };
21
- /**
22
- * Interface for memory storage operations to ByteRover CoGit service.
23
- * This service is responsible for uploading playbooks to blob storage.
24
- */
25
- export interface IMemoryStorageService {
26
- /**
27
- * Confirms that file upload is complete.
28
- * Notifies the server that all files have been successfully uploaded to blob storage.
29
- *
30
- * @param params Confirmation parameters including request ID from presigned URLs response
31
- * @returns Promise that resolves when confirmation succeeds
32
- * @throws Error if confirmation fails
33
- */
34
- confirmUpload: (params: ConfirmUploadParams) => Promise<void>;
35
- /**
36
- * Generates presigned URLs for uploading files to memory storage.
37
- *
38
- * @param params Request parameters including authentication, identifiers, and file list
39
- * @returns Response object containing presigned URLs and request ID for confirmation
40
- * @throws Error if the request fails
41
- */
42
- getPresignedUrls: (params: GetPresignedUrlsParams) => Promise<PresignedUrlsResponse>;
43
- /**
44
- * Uploads file content to a presigned URL.
45
- * Uses HTTP PUT with the file content in the request body.
46
- *
47
- * @param uploadUrl The presigned URL from Google Cloud Storage
48
- * @param content File content as string (typically JSON)
49
- * @returns Promise that resolves when upload completes
50
- * @throws Error if upload fails (network error, expired URL, etc.)
51
- */
52
- uploadFile: (uploadUrl: string, content: string) => Promise<void>;
53
- }
@@ -1,146 +0,0 @@
1
- /**
2
- * Choice option for select prompts.
3
- */
4
- export interface SelectChoice<T> {
5
- description?: string;
6
- name: string;
7
- value: T;
8
- }
9
- /**
10
- * Search source function type.
11
- */
12
- export type SearchSource<T> = (input: string | undefined) => Promise<SelectChoice<T>[]> | SelectChoice<T>[];
13
- /**
14
- * Options for confirm prompt.
15
- */
16
- export interface ConfirmOptions {
17
- /** The default value (default: true) */
18
- default?: boolean;
19
- /** The confirmation message */
20
- message: string;
21
- }
22
- /**
23
- * Options for search prompt.
24
- */
25
- export interface SearchOptions<T> {
26
- /** The prompt message */
27
- message: string;
28
- /** Function that returns choices based on input */
29
- source: SearchSource<T>;
30
- }
31
- /**
32
- * Options for select prompt.
33
- */
34
- export interface SelectOptions<T> {
35
- /** The available choices */
36
- choices: SelectChoice<T>[];
37
- /** The prompt message */
38
- message: string;
39
- }
40
- /**
41
- * Options for input prompt.
42
- */
43
- export interface InputOptions {
44
- /** The prompt message */
45
- message: string;
46
- /** Validation function (return true if valid, or error message string) */
47
- validate?: (value: string) => boolean | string;
48
- }
49
- /**
50
- * File selector item representation.
51
- */
52
- export interface FileSelectorItem {
53
- /** Whether the item is a directory */
54
- isDirectory: boolean;
55
- /** The file/directory name */
56
- name: string;
57
- /** The full path to the item */
58
- path: string;
59
- }
60
- /**
61
- * Options for file selector prompt.
62
- */
63
- export interface FileSelectorOptions {
64
- /** Allow user to cancel selection */
65
- allowCancel?: boolean;
66
- /** Base path to start selection from */
67
- basePath: string;
68
- /** Filter function to show/hide items */
69
- filter?: (item: Readonly<FileSelectorItem>) => boolean;
70
- /** The prompt message */
71
- message: string;
72
- /** Number of items to show per page */
73
- pageSize?: number;
74
- /** Custom theme labels */
75
- theme?: {
76
- labels?: {
77
- messages?: {
78
- cancel?: string;
79
- empty?: string;
80
- };
81
- };
82
- };
83
- /** Type of items to select: 'directory' or 'file' */
84
- type?: 'directory' | 'file';
85
- }
86
- /**
87
- * Interface for terminal interactions.
88
- * Provides output and user input operations.
89
- */
90
- export interface ITerminal {
91
- /**
92
- * Start a spinner/action indicator with a message.
93
- * @param message The message to display while action is in progress
94
- */
95
- actionStart(message: string): void;
96
- /**
97
- * Stop the current spinner/action indicator.
98
- * @param message Optional message to display when stopped
99
- */
100
- actionStop(message?: string): void;
101
- /**
102
- * Display a error message.
103
- * @param message The message to display
104
- */
105
- error(message: string): void;
106
- /**
107
- * Display a message to the terminal.
108
- * @param message The message to display (optional, empty line if omitted)
109
- */
110
- log(message?: string): void;
111
- /**
112
- * Display a warning message.
113
- * @param message The message to display
114
- */
115
- warn(message: string): void;
116
- /**
117
- * Prompt the user for confirmation.
118
- * @param options Confirmation options
119
- * @returns Promise resolving to user's choice
120
- */
121
- confirm(options: ConfirmOptions): Promise<boolean>;
122
- /**
123
- * Prompt the user to select a file or directory.
124
- * @param options File selector options
125
- * @returns Promise resolving to selected item, or null if cancelled
126
- */
127
- fileSelector(options: FileSelectorOptions): Promise<FileSelectorItem | null>;
128
- /**
129
- * Prompt the user for text input.
130
- * @param options Input options
131
- * @returns Promise resolving to user's input string
132
- */
133
- input(options: InputOptions): Promise<string>;
134
- /**
135
- * Prompt the user to search and select from options.
136
- * @param options Search options
137
- * @returns Promise resolving to selected value
138
- */
139
- search<T>(options: SearchOptions<T>): Promise<T>;
140
- /**
141
- * Prompt the user to select from a list of choices.
142
- * @param options Select options
143
- * @returns Promise resolving to selected value
144
- */
145
- select<T>(options: SelectOptions<T>): Promise<T>;
146
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { Agent } from '../../domain/entities/agent.js';
2
- export interface WorkspaceInfo {
3
- chatLogPath: string;
4
- cwd: string;
5
- }
6
- export interface IWorkspaceDetectorService {
7
- detectWorkspaces(agent: Agent): WorkspaceInfo;
8
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Store for onboarding preferences.
3
- * Used to persist when onboarding was last dismissed to implement
4
- * cooldown periods (e.g., show onboarding at most once per week).
5
- */
6
- export interface IOnboardingPreferenceStore {
7
- /**
8
- * Get the timestamp when onboarding was last dismissed.
9
- * Returns undefined if never dismissed.
10
- */
11
- getLastDismissedAt(): Promise<number | undefined>;
12
- /**
13
- * Set the timestamp when onboarding was dismissed.
14
- */
15
- setLastDismissedAt(timestamp: number): Promise<void>;
16
- /**
17
- * Clear the stored preference.
18
- */
19
- clear(): Promise<void>;
20
- }
@@ -1,21 +0,0 @@
1
- import type { Agent } from '../../../core/domain/entities/agent.js';
2
- import type { ILegacyRuleDetector, LegacyRuleDetectionResult } from '../../../core/interfaces/services/i-legacy-rule-detector.js';
3
- export declare class LegacyRuleDetector implements ILegacyRuleDetector {
4
- private static readonly SECTION_SEPARATOR_PATTERN;
5
- private static readonly WORKFLOW_HEADER_PATTERN;
6
- detectLegacyRules(content: string, agentName: Agent): LegacyRuleDetectionResult;
7
- /**
8
- * Attempts to find the start of a ByteRover rule section by working backwards from the footer.
9
- *
10
- * Strategy 3 (Conservative Multi-Pattern Match):
11
- * 1. Look backwards for "# Workflow Instruction" header (most reliable)
12
- * 2. If not found, look backwards for "---" separator before command reference
13
- * 3. If still not found, return undefined (uncertain)
14
- *
15
- * @param lines All lines in the file.
16
- * @param footerIndex Index of the line containing the footer tag (0-indexed).
17
- * @param usedLineRanges Line ranges already claimed by detected sections.
18
- * @returns Index of the start line (0-indexed), or undefined if uncertain.
19
- */
20
- private findSectionStart;
21
- }
@@ -1,106 +0,0 @@
1
- import { BRV_RULE_TAG } from '../shared/constants.js';
2
- export class LegacyRuleDetector {
3
- static SECTION_SEPARATOR_PATTERN = /^---\s*$/;
4
- static WORKFLOW_HEADER_PATTERN = /^#\sWorkflow Instruction$/;
5
- detectLegacyRules(content, agentName) {
6
- // Normalize line endings to handle CRLF
7
- const normalizedContent = content.replaceAll('\r\n', '\n').replaceAll('\r', '\n');
8
- const lines = normalizedContent.split('\n');
9
- const footerTag = `${BRV_RULE_TAG} ${agentName}`;
10
- const reliableMatches = [];
11
- const uncertainMatches = [];
12
- const usedLineRanges = [];
13
- // Find all occurrences of the footer tag
14
- for (const [index, line] of lines.entries()) {
15
- // Use exact match to avoid matching partial agent names like "Github Copilot Extended"
16
- if (line.trim() === footerTag) {
17
- const footerIndex = index;
18
- const footerLineNumber = footerIndex + 1;
19
- // Try to find the start of this ByteRover section
20
- const startIndex = this.findSectionStart(lines, footerIndex, usedLineRanges);
21
- if (startIndex === undefined) {
22
- // Uncertain match - couldn't reliably determine start
23
- uncertainMatches.push({
24
- footerLine: footerLineNumber,
25
- reason: 'Could not reliably determine the start of the ByteRover rule section.',
26
- });
27
- }
28
- else {
29
- // Reliable match found
30
- const startLineNumber = startIndex + 1;
31
- const sectionContent = lines.slice(startIndex, footerIndex + 1).join('\n');
32
- reliableMatches.push({
33
- content: sectionContent,
34
- endLine: footerLineNumber,
35
- startLine: startLineNumber,
36
- });
37
- // Mark this range as used so it won't be reused by subsequent footers
38
- usedLineRanges.push({ end: footerIndex, start: startIndex });
39
- }
40
- }
41
- }
42
- return { reliableMatches, uncertainMatches };
43
- }
44
- /**
45
- * Attempts to find the start of a ByteRover rule section by working backwards from the footer.
46
- *
47
- * Strategy 3 (Conservative Multi-Pattern Match):
48
- * 1. Look backwards for "# Workflow Instruction" header (most reliable)
49
- * 2. If not found, look backwards for "---" separator before command reference
50
- * 3. If still not found, return undefined (uncertain)
51
- *
52
- * @param lines All lines in the file.
53
- * @param footerIndex Index of the line containing the footer tag (0-indexed).
54
- * @param usedLineRanges Line ranges already claimed by detected sections.
55
- * @returns Index of the start line (0-indexed), or undefined if uncertain.
56
- */
57
- findSectionStart(lines, footerIndex, usedLineRanges) {
58
- // Strategy 1: Look for "# Workflow Instruction" header (most reliable)
59
- for (let i = footerIndex - 1; i >= 0; i--) {
60
- if (LegacyRuleDetector.WORKFLOW_HEADER_PATTERN.test(lines[i])) {
61
- // Check if this header is within any already-detected section
62
- const isWithinUsedRange = usedLineRanges.some((range) => i >= range.start && i <= range.end);
63
- if (!isWithinUsedRange) {
64
- return i;
65
- }
66
- }
67
- }
68
- // Strategy 2: Look for "---" separator
69
- // We need to find the section separator that appears before the command reference
70
- // and after the workflow content. This is less reliable but still useful.
71
- const separatorIndices = [];
72
- for (let i = footerIndex - 1; i >= 0; i--) {
73
- if (LegacyRuleDetector.SECTION_SEPARATOR_PATTERN.test(lines[i])) {
74
- separatorIndices.push(i);
75
- }
76
- }
77
- // If we found at least one separator, use it as a fallback
78
- // We want the one closest to the footer but before the "---" that precedes the footer
79
- if (separatorIndices.length > 0) {
80
- // The footer line should be preceded by "---", so we skip that one
81
- // and look for the next separator going backwards
82
- let candidateIndex;
83
- for (const sepIndex of separatorIndices) {
84
- const linesBetween = footerIndex - sepIndex;
85
- if (linesBetween === 1) {
86
- // This is the separator right before the footer, skip it
87
- continue;
88
- }
89
- // Check if this separator is within any already-detected section
90
- const isWithinUsedRange = usedLineRanges.some((range) => sepIndex >= range.start && sepIndex <= range.end);
91
- if (isWithinUsedRange) {
92
- continue;
93
- }
94
- // This could be a section separator within the ByteRover content
95
- // Use the first one we find (closest to footer)
96
- candidateIndex = sepIndex + 1;
97
- break;
98
- }
99
- if (candidateIndex !== undefined && candidateIndex < footerIndex) {
100
- return candidateIndex;
101
- }
102
- }
103
- // Strategy 3: Could not reliably determine start
104
- return undefined;
105
- }
106
- }
@@ -1,18 +0,0 @@
1
- import type { IMemoryRetrievalService, RetrieveParams } from '../../core/interfaces/services/i-memory-retrieval-service.js';
2
- import { RetrieveResult } from '../../core/domain/entities/retrieve-result.js';
3
- export type MemoryRetrievalServiceConfig = {
4
- apiBaseUrl: string;
5
- timeout?: number;
6
- };
7
- /**
8
- * HTTP implementation of IMemoryRetrievalService for ByteRover Memora service.
9
- * Handles retrieval of memories based on search queries.
10
- */
11
- export declare class HttpMemoryRetrievalService implements IMemoryRetrievalService {
12
- private readonly config;
13
- constructor(config: MemoryRetrievalServiceConfig);
14
- retrieve(params: RetrieveParams): Promise<RetrieveResult>;
15
- private buildQueryParams;
16
- private mapToMemory;
17
- private mapToRetrieveResult;
18
- }
@@ -1,64 +0,0 @@
1
- import { Memory } from '../../core/domain/entities/memory.js';
2
- import { RetrieveResult } from '../../core/domain/entities/retrieve-result.js';
3
- import { getErrorMessage } from '../../utils/error-helpers.js';
4
- import { AuthenticatedHttpClient } from '../http/authenticated-http-client.js';
5
- /**
6
- * HTTP implementation of IMemoryRetrievalService for ByteRover Memora service.
7
- * Handles retrieval of memories based on search queries.
8
- */
9
- export class HttpMemoryRetrievalService {
10
- config;
11
- constructor(config) {
12
- this.config = {
13
- ...config,
14
- timeout: config.timeout ?? 30_000, // Default 30 seconds timeout (memory retrieval may be slower)
15
- };
16
- }
17
- async retrieve(params) {
18
- try {
19
- const httpClient = new AuthenticatedHttpClient(params.sessionKey);
20
- // Build query parameters
21
- const queryParams = this.buildQueryParams(params);
22
- const response = await httpClient.get(`${this.config.apiBaseUrl}/retrieve?${queryParams}`, {
23
- timeout: this.config.timeout,
24
- });
25
- return this.mapToRetrieveResult(response);
26
- }
27
- catch (error) {
28
- throw new Error(`Failed to retrieve memories: ${getErrorMessage(error)}`);
29
- }
30
- }
31
- buildQueryParams(params) {
32
- const queryParams = new URLSearchParams({
33
- project_id: params.spaceId,
34
- query: params.query,
35
- });
36
- // Add node_keys only if provided
37
- if (params.nodeKeys !== undefined && params.nodeKeys.length > 0) {
38
- queryParams.set('node_keys', params.nodeKeys.join(','));
39
- }
40
- return queryParams.toString();
41
- }
42
- mapToMemory(apiMemory) {
43
- return new Memory({
44
- bulletId: apiMemory.bullet_id,
45
- childrenIds: apiMemory.children_ids,
46
- content: apiMemory.content,
47
- id: apiMemory.id,
48
- metadataType: apiMemory.metadata_type,
49
- nodeKeys: apiMemory.node_keys,
50
- parentIds: apiMemory.parent_ids,
51
- score: apiMemory.score,
52
- section: apiMemory.section,
53
- tags: apiMemory.tags,
54
- timestamp: apiMemory.timestamp,
55
- title: apiMemory.title,
56
- });
57
- }
58
- mapToRetrieveResult(response) {
59
- return new RetrieveResult({
60
- memories: response.memories.map((m) => this.mapToMemory(m)),
61
- relatedMemories: response.related_memories.map((m) => this.mapToMemory(m)),
62
- });
63
- }
64
- }
@@ -1,18 +0,0 @@
1
- import type { ConfirmUploadParams, GetPresignedUrlsParams, IMemoryStorageService } from '../../core/interfaces/services/i-memory-storage-service.js';
2
- import { PresignedUrlsResponse } from '../../core/domain/entities/presigned-urls-response.js';
3
- export type MemoryStorageServiceConfig = {
4
- apiBaseUrl: string;
5
- timeout?: number;
6
- };
7
- /**
8
- * HTTP implementation of IMemoryStorageService for ByteRover CoGit service.
9
- * Handles uploading playbooks to blob storage.
10
- */
11
- export declare class HttpMemoryStorageService implements IMemoryStorageService {
12
- private readonly config;
13
- constructor(config: MemoryStorageServiceConfig);
14
- confirmUpload(params: ConfirmUploadParams): Promise<void>;
15
- getPresignedUrls(params: GetPresignedUrlsParams): Promise<PresignedUrlsResponse>;
16
- uploadFile(uploadUrl: string, content: string): Promise<void>;
17
- private mapToPresignedUrls;
18
- }
@@ -1,72 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import axios from 'axios';
3
- import { PresignedUrl } from '../../core/domain/entities/presigned-url.js';
4
- import { PresignedUrlsResponse } from '../../core/domain/entities/presigned-urls-response.js';
5
- import { getErrorMessage } from '../../utils/error-helpers.js';
6
- import { AuthenticatedHttpClient } from '../http/authenticated-http-client.js';
7
- import { ProxyConfig } from '../http/proxy-config.js';
8
- /**
9
- * HTTP implementation of IMemoryStorageService for ByteRover CoGit service.
10
- * Handles uploading playbooks to blob storage.
11
- */
12
- export class HttpMemoryStorageService {
13
- config;
14
- constructor(config) {
15
- this.config = {
16
- ...config,
17
- timeout: config.timeout ?? 30_000, // Default 30 seconds timeout
18
- };
19
- }
20
- async confirmUpload(params) {
21
- try {
22
- const httpClient = new AuthenticatedHttpClient(params.sessionKey);
23
- const url = `${this.config.apiBaseUrl}/organizations/${params.teamId}/projects/${params.spaceId}/memory-processing/confirm-upload`;
24
- const requestBody = {
25
- request_id: params.requestId,
26
- };
27
- await httpClient.post(url, requestBody, {
28
- timeout: this.config.timeout,
29
- });
30
- }
31
- catch (error) {
32
- throw new Error(`Failed to confirm upload: ${getErrorMessage(error)}`);
33
- }
34
- }
35
- async getPresignedUrls(params) {
36
- try {
37
- const httpClient = new AuthenticatedHttpClient(params.sessionKey);
38
- const url = `${this.config.apiBaseUrl}/organizations/${params.teamId}/projects/${params.spaceId}/memory-processing/presigned-urls`;
39
- const requestBody = {
40
- branch: params.branch,
41
- file_names: params.fileNames,
42
- };
43
- const response = await httpClient.post(url, requestBody, {
44
- timeout: this.config.timeout,
45
- });
46
- const presignedUrls = response.data.presigned_urls.map((presignedUrlData) => this.mapToPresignedUrls(presignedUrlData));
47
- return new PresignedUrlsResponse(presignedUrls, response.data.request_id);
48
- }
49
- catch (error) {
50
- throw new Error(`Failed to get presigned URLs: ${getErrorMessage(error)}`);
51
- }
52
- }
53
- async uploadFile(uploadUrl, content) {
54
- try {
55
- await axios.put(uploadUrl, content, {
56
- headers: {
57
- 'Content-Type': 'application/json',
58
- },
59
- httpAgent: ProxyConfig.getProxyAgent(),
60
- httpsAgent: ProxyConfig.getProxyAgent(),
61
- proxy: false,
62
- timeout: this.config.timeout,
63
- });
64
- }
65
- catch (error) {
66
- throw new Error(`Failed to upload file: ${getErrorMessage(error)}`);
67
- }
68
- }
69
- mapToPresignedUrls(presignedUrlData) {
70
- return new PresignedUrl(presignedUrlData.file_name, presignedUrlData.presigned_url);
71
- }
72
- }
@@ -1,33 +0,0 @@
1
- import type { Memory } from '../../core/domain/entities/memory.js';
2
- import type { RetrieveResult } from '../../core/domain/entities/retrieve-result.js';
3
- import { Bullet } from '../../core/domain/entities/bullet.js';
4
- import { Playbook } from '../../core/domain/entities/playbook.js';
5
- /**
6
- * Transforms a Memory entity into a Bullet entity for playbook storage.
7
- *
8
- * Mapping:
9
- * - memory.bulletId -> bullet.id
10
- * - memory.section -> bullet.section
11
- * - memory.content -> bullet.content
12
- * - memory.tags -> bullet.metadata.tags
13
- * - memory.nodeKeys -> bullet.metadata.relatedFiles
14
- * - memory.timestamp -> bullet.metadata.timestamp
15
- * - memory.id -> bullet.memoryId
16
- *
17
- * @param memory The Memory entity to transform
18
- * @returns A Bullet entity
19
- */
20
- export declare const transformMemoryToBullet: (memory: Memory) => Bullet;
21
- /**
22
- * Transforms a RetrieveResult into a Playbook.
23
- *
24
- * This function:
25
- * 1. Combines both memories and relatedMemories from the result
26
- * 2. Transforms each Memory into a Bullet
27
- * 3. Organizes bullets by section
28
- * 4. Creates a new Playbook with nextId set to 1 (reset value)
29
- *
30
- * @param result The RetrieveResult containing memories from Memora service
31
- * @returns A Playbook containing all retrieved memories as bullets
32
- */
33
- export declare const transformRetrieveResultToPlaybook: (result: RetrieveResult) => Playbook;
@@ -1,51 +0,0 @@
1
- import { Bullet } from '../../core/domain/entities/bullet.js';
2
- import { Playbook } from '../../core/domain/entities/playbook.js';
3
- /**
4
- * Transforms a Memory entity into a Bullet entity for playbook storage.
5
- *
6
- * Mapping:
7
- * - memory.bulletId -> bullet.id
8
- * - memory.section -> bullet.section
9
- * - memory.content -> bullet.content
10
- * - memory.tags -> bullet.metadata.tags
11
- * - memory.nodeKeys -> bullet.metadata.relatedFiles
12
- * - memory.timestamp -> bullet.metadata.timestamp
13
- * - memory.id -> bullet.memoryId
14
- *
15
- * @param memory The Memory entity to transform
16
- * @returns A Bullet entity
17
- */
18
- export const transformMemoryToBullet = (memory) => {
19
- const metadata = {
20
- relatedFiles: [...memory.nodeKeys],
21
- tags: [...memory.tags],
22
- timestamp: memory.timestamp,
23
- };
24
- return new Bullet(memory.bulletId, memory.section, memory.content, metadata, memory.id);
25
- };
26
- /**
27
- * Transforms a RetrieveResult into a Playbook.
28
- *
29
- * This function:
30
- * 1. Combines both memories and relatedMemories from the result
31
- * 2. Transforms each Memory into a Bullet
32
- * 3. Organizes bullets by section
33
- * 4. Creates a new Playbook with nextId set to 1 (reset value)
34
- *
35
- * @param result The RetrieveResult containing memories from Memora service
36
- * @returns A Playbook containing all retrieved memories as bullets
37
- */
38
- export const transformRetrieveResultToPlaybook = (result) => {
39
- const bulletsMap = new Map();
40
- const sectionsMap = new Map();
41
- const allMemories = [...result.memories, ...result.relatedMemories];
42
- for (const memory of allMemories) {
43
- const bullet = transformMemoryToBullet(memory);
44
- bulletsMap.set(bullet.id, bullet);
45
- if (!sectionsMap.has(bullet.section)) {
46
- sectionsMap.set(bullet.section, []);
47
- }
48
- sectionsMap.get(bullet.section).push(bullet.id);
49
- }
50
- return new Playbook(bulletsMap, sectionsMap, bulletsMap.size + 1);
51
- };
@@ -1,10 +0,0 @@
1
- import type { IOnboardingPreferenceStore } from '../../core/interfaces/storage/i-onboarding-preference-store.js';
2
- /**
3
- * Onboarding preference store implementation using a lock file.
4
- * Stores last dismissed timestamp in XDG data directory.
5
- */
6
- export declare class FileOnboardingPreferenceStore implements IOnboardingPreferenceStore {
7
- clear(): Promise<void>;
8
- getLastDismissedAt(): Promise<number | undefined>;
9
- setLastDismissedAt(timestamp: number): Promise<void>;
10
- }