clanka 0.2.69 → 0.2.71

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 (74) hide show
  1. package/dist/Agent.d.ts +2 -2
  2. package/dist/Agent.d.ts.map +1 -1
  3. package/dist/Agent.js +4 -1
  4. package/dist/Agent.js.map +1 -1
  5. package/dist/Agent.test.js.map +1 -1
  6. package/dist/AgentExecutor.d.ts +136 -136
  7. package/dist/AgentExecutor.d.ts.map +1 -1
  8. package/dist/AgentExecutor.js.map +1 -1
  9. package/dist/AgentOutput.d.ts +1 -0
  10. package/dist/AgentOutput.d.ts.map +1 -1
  11. package/dist/AgentOutput.js +1 -0
  12. package/dist/AgentOutput.js.map +1 -1
  13. package/dist/AgentTools.d.ts +270 -270
  14. package/dist/AgentTools.d.ts.map +1 -1
  15. package/dist/AgentTools.js +1 -0
  16. package/dist/AgentTools.js.map +1 -1
  17. package/dist/ApplyPatch.d.ts.map +1 -1
  18. package/dist/ChunkRepo.d.ts +18 -17
  19. package/dist/ChunkRepo.d.ts.map +1 -1
  20. package/dist/ChunkRepo.js +37 -21
  21. package/dist/ChunkRepo.js.map +1 -1
  22. package/dist/ChunkRepo.test.d.ts +2 -0
  23. package/dist/ChunkRepo.test.d.ts.map +1 -0
  24. package/dist/ChunkRepo.test.js +63 -0
  25. package/dist/ChunkRepo.test.js.map +1 -0
  26. package/dist/CodeChunker.d.ts.map +1 -1
  27. package/dist/CodeChunker.js +1 -1
  28. package/dist/CodeChunker.js.map +1 -1
  29. package/dist/Codex.d.ts +1 -1
  30. package/dist/Codex.d.ts.map +1 -1
  31. package/dist/CodexAuth.d.ts +5 -4
  32. package/dist/CodexAuth.d.ts.map +1 -1
  33. package/dist/CodexAuth.js +5 -1
  34. package/dist/CodexAuth.js.map +1 -1
  35. package/dist/Copilot.d.ts +1 -1
  36. package/dist/Copilot.d.ts.map +1 -1
  37. package/dist/CopilotAuth.d.ts +5 -4
  38. package/dist/CopilotAuth.d.ts.map +1 -1
  39. package/dist/CopilotAuth.js +5 -1
  40. package/dist/CopilotAuth.js.map +1 -1
  41. package/dist/ExaSearch.d.ts.map +1 -1
  42. package/dist/ExaSearch.js +1 -0
  43. package/dist/ExaSearch.js.map +1 -1
  44. package/dist/OutputFormatter.d.ts.map +1 -1
  45. package/dist/OutputFormatter.js.map +1 -1
  46. package/dist/ScriptExtraction.d.ts.map +1 -1
  47. package/dist/ScriptPreprocessing.d.ts.map +1 -1
  48. package/dist/SemanticSearch/Service.d.ts.map +1 -1
  49. package/dist/SemanticSearch.d.ts.map +1 -1
  50. package/dist/Sqlite.d.ts +1 -1
  51. package/dist/Sqlite.d.ts.map +1 -1
  52. package/dist/Sqlite.js +2 -2
  53. package/dist/Sqlite.js.map +1 -1
  54. package/dist/ToolkitRenderer.js.map +1 -1
  55. package/dist/TypeBuilder.d.ts.map +1 -1
  56. package/dist/TypeBuilder.test.js +1 -0
  57. package/dist/TypeBuilder.test.js.map +1 -1
  58. package/package.json +21 -30
  59. package/src/Agent.ts +4 -4
  60. package/src/AgentOutput.ts +2 -5
  61. package/src/AgentTools.ts +1 -0
  62. package/src/ChunkRepo.test.ts +89 -0
  63. package/src/ChunkRepo.ts +38 -21
  64. package/src/CodeChunker.ts +3 -3
  65. package/src/CodexAuth.ts +5 -3
  66. package/src/CopilotAuth.ts +5 -3
  67. package/src/ExaSearch.ts +1 -0
  68. package/src/Sqlite.ts +2 -2
  69. package/src/TypeBuilder.test.ts +1 -0
  70. package/dist/internal/sqlite-vector.d.ts +0 -16
  71. package/dist/internal/sqlite-vector.d.ts.map +0 -1
  72. package/dist/internal/sqlite-vector.js +0 -181
  73. package/dist/internal/sqlite-vector.js.map +0 -1
  74. package/src/internal/sqlite-vector.ts +0 -214
@@ -1,214 +0,0 @@
1
- import { resolve } from "node:path"
2
- import { platform, arch } from "node:os"
3
- import { existsSync, readFileSync } from "node:fs"
4
- import { execSync } from "node:child_process"
5
-
6
- /**
7
- * Supported platform identifiers
8
- */
9
- type Platform =
10
- | "darwin-arm64"
11
- | "darwin-x86_64"
12
- | "linux-arm64"
13
- | "linux-arm64-musl"
14
- | "linux-x86_64"
15
- | "linux-x86_64-musl"
16
- | "win32-x86_64"
17
-
18
- /**
19
- * Binary extension for each platform
20
- */
21
- const PLATFORM_EXTENSIONS: Record<string, string> = {
22
- darwin: ".dylib",
23
- linux: ".so",
24
- win32: ".dll",
25
- } as const
26
-
27
- /**
28
- * Detects if the system uses musl libc (Alpine Linux, etc.)
29
- * Uses multiple detection strategies for reliability
30
- */
31
- function isMusl(): boolean {
32
- // Only relevant for Linux
33
- if (platform() !== "linux") {
34
- return false
35
- }
36
-
37
- // Strategy 1: Check for musl-specific files
38
- const muslFiles = [
39
- "/lib/ld-musl-x86_64.so.1",
40
- "/lib/ld-musl-aarch64.so.1",
41
- "/lib/ld-musl-armhf.so.1",
42
- ]
43
-
44
- for (const file of muslFiles) {
45
- if (existsSync(file)) {
46
- return true
47
- }
48
- }
49
-
50
- // Strategy 2: Check ldd version output
51
- try {
52
- const lddVersion = execSync("ldd --version 2>&1", {
53
- encoding: "utf-8",
54
- stdio: ["pipe", "pipe", "pipe"],
55
- })
56
-
57
- if (lddVersion.includes("musl")) {
58
- return true
59
- }
60
- } catch {
61
- // ldd command failed, continue to next strategy
62
- }
63
-
64
- // Strategy 3: Check /etc/os-release for Alpine
65
- try {
66
- if (existsSync("/etc/os-release")) {
67
- const osRelease = readFileSync("/etc/os-release", "utf-8")
68
- if (osRelease.includes("Alpine") || osRelease.includes("musl")) {
69
- return true
70
- }
71
- }
72
- } catch {
73
- // File read failed, continue to next strategy
74
- }
75
-
76
- // Strategy 4: Check process.report.getReport() for musl
77
- try {
78
- const report = (process as any).report?.getReport?.()
79
- if (report?.header?.glibcVersionRuntime === "") {
80
- // Empty glibc version often indicates musl
81
- return true
82
- }
83
- } catch {
84
- // Report not available
85
- }
86
-
87
- return false
88
- }
89
-
90
- /**
91
- * Gets the current platform identifier
92
- * @throws {Error} If the platform is unsupported
93
- */
94
- function getCurrentPlatform(): Platform {
95
- const platformName = platform()
96
- const archName = arch()
97
-
98
- // macOS
99
- if (platformName === "darwin") {
100
- if (archName === "arm64") return "darwin-arm64"
101
- if (archName === "x64" || archName === "ia32") return "darwin-x86_64"
102
- }
103
-
104
- // Linux (with musl detection)
105
- if (platformName === "linux") {
106
- const muslSuffix = isMusl() ? "-musl" : ""
107
-
108
- if (archName === "arm64") {
109
- return `linux-arm64${muslSuffix}` as Platform
110
- }
111
- if (archName === "x64" || archName === "ia32") {
112
- return `linux-x86_64${muslSuffix}` as Platform
113
- }
114
- }
115
-
116
- // Windows
117
- if (platformName === "win32") {
118
- if (archName === "x64" || archName === "ia32") return "win32-x86_64"
119
- }
120
-
121
- // Unsupported platform
122
- throw new Error(
123
- `Unsupported platform: ${platformName}-${archName}. ` +
124
- `Supported platforms: darwin-arm64, darwin-x86_64, linux-arm64, linux-x86_64, win32-x86_64 ` +
125
- `(with glibc or musl support for Linux)`,
126
- )
127
- }
128
-
129
- /**
130
- * Gets the package name for the current platform
131
- */
132
- function getPlatformPackageName(): string {
133
- const currentPlatform = getCurrentPlatform()
134
- return `@sqliteai/sqlite-vector-${currentPlatform}`
135
- }
136
-
137
- /**
138
- * Gets the binary filename for the current platform
139
- */
140
- function getBinaryName(): string {
141
- const platformName = platform()
142
- const extension = PLATFORM_EXTENSIONS[platformName]
143
-
144
- if (!extension) {
145
- throw new Error(`Unknown platform: ${platformName}`)
146
- }
147
-
148
- return `vector${extension}`
149
- }
150
-
151
- /**
152
- * Error thrown when the SQLite Vector extension cannot be found
153
- */
154
- class ExtensionNotFoundError extends Error {
155
- constructor(message: string) {
156
- super(message)
157
- this.name = "ExtensionNotFoundError"
158
- }
159
- }
160
-
161
- /**
162
- * Attempts to load the platform-specific package
163
- * @returns The path to the extension binary, or null if not found
164
- */
165
- function tryLoadPlatformPackage(): string | null {
166
- try {
167
- const packageName = getPlatformPackageName()
168
- const platformPackage = import.meta.resolve(packageName)
169
- return platformPackage
170
- .replace(/\/index\.js$/, `/${getBinaryName()}`)
171
- .replace("file://", "")
172
- } catch {
173
- // Platform package not installed or failed to load
174
- // This is expected when optionalDependencies fail
175
- }
176
-
177
- return null
178
- }
179
-
180
- /**
181
- * Gets the absolute path to the SQLite Vector extension binary for the current platform
182
- *
183
- * @returns Absolute path to the extension binary (.so, .dylib, or .dll)
184
- * @throws {ExtensionNotFoundError} If the extension binary cannot be found
185
- *
186
- * @example
187
- * ```typescript
188
- * import { getExtensionPath } from '@sqliteai/sqlite-vector';
189
- *
190
- * const extensionPath = getExtensionPath();
191
- * // On macOS ARM64: /path/to/node_modules/@sqliteai/sqlite-vector-darwin-arm64/vector.dylib
192
- * ```
193
- */
194
- export function getExtensionPath(): string {
195
- // Try to load from platform-specific package
196
- const platformPath = tryLoadPlatformPackage()
197
- if (platformPath) {
198
- return resolve(platformPath)
199
- }
200
-
201
- // If we reach here, the platform package wasn't installed
202
- const currentPlatform = getCurrentPlatform()
203
- const packageName = getPlatformPackageName()
204
-
205
- throw new ExtensionNotFoundError(
206
- `SQLite Vector extension not found for platform: ${currentPlatform}\n\n` +
207
- `The platform-specific package "${packageName}" is not installed.\n` +
208
- `This usually happens when:\n` +
209
- ` 1. Your platform is not supported\n` +
210
- ` 2. npm failed to install optional dependencies\n` +
211
- ` 3. You're installing with --no-optional flag\n\n` +
212
- `Try running: npm install --force`,
213
- )
214
- }