Skip to content

Commit 222ad39

Browse files
committed
fix(sdk): resolve dts-bundle-generator module resolution errors
- Add path mappings for @codebuff workspace packages in tsconfig.json - Convert relative imports to package imports in index.ts - Configure importedLibraries to mark workspace packages as external - Export getFileTokenScores and setWasmDir from @codebuff/code-map Fixes env-schema module not found error and smoke test failures.
1 parent 2e4bdfe commit 222ad39

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

sdk/scripts/build.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ async function build() {
9999
output: {
100100
exportReferencedTypes: false,
101101
},
102+
libraries: {
103+
// Treat all @codebuff/* workspace packages as external imports
104+
// so dts-bundle-generator doesn't fail on their internal relative imports
105+
importedLibraries: [
106+
'@codebuff/common',
107+
'@codebuff/agent-runtime',
108+
'@codebuff/code-map',
109+
],
110+
},
102111
},
103112
],
104113
{

sdk/src/index.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export type * from '../../common/src/types/json'
2-
export type * from '../../common/src/types/messages/codebuff-message'
3-
export type * from '../../common/src/types/messages/data-content'
4-
export type * from '../../common/src/types/print-mode'
1+
export type * from '@codebuff/common/types/json'
2+
export type * from '@codebuff/common/types/messages/codebuff-message'
3+
export type * from '@codebuff/common/types/messages/data-content'
4+
export type * from '@codebuff/common/types/print-mode'
55
export type {
66
TextPart,
77
ImagePart,
8-
} from '../../common/src/types/messages/content-part'
8+
} from '@codebuff/common/types/messages/content-part'
99
export { run, getRetryableErrorCode } from './run'
1010
export type {
1111
RunOptions,
@@ -14,16 +14,16 @@ export type {
1414
TextContent,
1515
ImageContent,
1616
} from './run'
17-
export { buildUserMessageContent } from '../../packages/agent-runtime/src/util/messages'
17+
export { buildUserMessageContent } from '@codebuff/agent-runtime/util/messages'
1818
// Agent type exports
19-
export type { AgentDefinition } from '../../common/src/templates/initial-agents-dir/types/agent-definition'
20-
export type { ToolName } from '../../common/src/tools/constants'
19+
export type { AgentDefinition } from '@codebuff/common/templates/initial-agents-dir/types/agent-definition'
20+
export type { ToolName } from '@codebuff/common/tools/constants'
2121

2222
export type {
2323
ClientToolCall,
2424
ClientToolName,
2525
CodebuffToolOutput,
26-
} from '../../common/src/tools/list'
26+
} from '@codebuff/common/tools/list'
2727
export * from './client'
2828
export * from './custom-tool'
2929
export * from './native/ripgrep'
@@ -70,6 +70,10 @@ export {
7070

7171
export type { CodebuffFileSystem } from '@codebuff/common/types/filesystem'
7272

73+
// Tree-sitter / code-map exports
74+
export { getFileTokenScores, setWasmDir } from '@codebuff/code-map'
75+
export type { FileTokenData, TokenCallerMap } from '@codebuff/code-map'
76+
7377
export { runTerminalCommand } from './tools/run-terminal-command'
7478
export {
7579
promptAiSdk,

sdk/tsconfig.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
"declaration": true,
1313
"outDir": "./dist",
1414
"allowImportingTsExtensions": false,
15-
"types": ["node", "bun-types"]
15+
"types": ["node", "bun-types"],
16+
"baseUrl": ".",
17+
"paths": {
18+
"@codebuff/common/*": ["../common/src/*"],
19+
"@codebuff/agent-runtime/*": ["../packages/agent-runtime/src/*"],
20+
"@codebuff/code-map": ["../packages/code-map/src/index.ts"],
21+
"@codebuff/code-map/*": ["../packages/code-map/src/*"]
22+
}
1623
},
1724
"include": ["src/**/*.ts"],
1825
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)