-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_source.ts
More file actions
209 lines (194 loc) · 4.36 KB
/
data_source.ts
File metadata and controls
209 lines (194 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/**
* Data source types and interfaces for the BB Tools Framework.
* Provides minimal type definitions for data source connections as seen by tools.
*
* Note: These are simplified versions of the full BB implementation types.
* They expose only what tools need to work with data sources.
*
* @module
*/
/**
* Data source provider types supported by BB.
* Identifies the underlying provider technology.
*
* @example
* ```ts
* const type: DataSourceProviderType = 'filesystem';
* ```
*/
export type DataSourceProviderType =
| 'filesystem'
| 'google'
| 'notion'
| 'supabase'
| 'mcp'
| 'unknown';
/**
* Data source access methods.
* Indicates how BB interacts with the data source.
*
* @example
* ```ts
* const method: DataSourceAccessMethod = 'bb';
* ```
*/
export type DataSourceAccessMethod = 'bb' | 'mcp';
/**
* Capabilities that a data source may support.
* Tools can check these to determine what operations are available.
*
* @example
* ```ts
* const capabilities: DataSourceCapability[] = ['read', 'write', 'list'];
* ```
*/
export type DataSourceCapability =
| 'read'
| 'write'
| 'list'
| 'search'
| 'move'
| 'delete';
/**
* Data source configuration.
* Provider-specific settings (simplified for tool access).
*
* @example
* ```ts
* const config: DataSourceConfig = {
* dataSourceRoot: '/path/to/project'
* };
* ```
*/
export interface DataSourceConfig {
dataSourceRoot?: string; // For filesystem type
[key: string]: unknown; // Provider-specific settings
}
/**
* Data source connection interface.
* Represents a configured data source instance as seen by tools.
*
* This is a minimal interface exposing only what tools need.
* The full implementation in BB has additional methods and properties.
*
* @example
* ```ts
* function checkDataSource(ds: DataSourceConnection) {
* console.log(`${ds.name} (${ds.providerType})`);
* console.log(`Can write: ${ds.capabilities.includes('write')}`);
* console.log(`Read-only: ${ds.readonly}`);
* }
* ```
*/
export interface DataSourceConnection {
/**
* Unique identifier for this connection.
*
* @example
* ```ts
* const id = dsConnection.id; // 'ds-abc123'
* ```
*/
readonly id: string;
/**
* Human-readable name for this connection.
*
* @example
* ```ts
* const name = dsConnection.name; // 'project-files'
* ```
*/
name: string;
/**
* Provider type (filesystem, google, notion, etc.).
*
* @example
* ```ts
* if (dsConnection.providerType === 'filesystem') {
* // Handle filesystem-specific logic
* }
* ```
*/
readonly providerType: DataSourceProviderType;
/**
* Access method (bb or mcp).
*
* @example
* ```ts
* const method = dsConnection.accessMethod; // 'bb'
* ```
*/
readonly accessMethod: DataSourceAccessMethod;
/**
* Capabilities this data source supports.
*
* @example
* ```ts
* const canWrite = dsConnection.capabilities.includes('write');
* const canSearch = dsConnection.capabilities.includes('search');
* ```
*/
readonly capabilities: DataSourceCapability[];
/**
* Provider-specific configuration.
*
* @example
* ```ts
* if (dsConnection.providerType === 'filesystem') {
* const root = dsConnection.config.dataSourceRoot;
* }
* ```
*/
config: DataSourceConfig;
/**
* Whether this connection is currently enabled.
*
* @example
* ```ts
* if (!dsConnection.enabled) {
* console.warn('Data source is disabled');
* }
* ```
*/
enabled: boolean;
/**
* Whether this connection is read-only.
*
* @example
* ```ts
* if (dsConnection.readonly) {
* console.log('Cannot modify resources in this data source');
* }
* ```
*/
readonly: boolean;
/**
* Whether this is the primary data source.
*
* @example
* ```ts
* if (dsConnection.isPrimary) {
* console.log('This is the default data source');
* }
* ```
*/
isPrimary: boolean;
/**
* URI prefix for resources in this data source.
*
* @example
* ```ts
* const prefix = dsConnection.uriPrefix; // 'bb+filesystem+project+file:'
* ```
*/
uriPrefix?: string;
/**
* URI template for constructing resource URIs.
*
* @example
* ```ts
* const template = dsConnection.uriTemplate; // 'bb+filesystem+project+file:./{path}'
* ```
*/
uriTemplate?: string;
}