@makerbi/openclaude 0.13.0 → 0.14.3
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.
- package/LICENSE +29 -29
- package/README.md +373 -373
- package/bin/import-specifier.mjs +13 -13
- package/bin/import-specifier.test.mjs +13 -13
- package/bin/openclaude +97 -32
- package/dist/cli.mjs +14622 -9082
- package/dist/sdk.mjs +8818 -5170
- package/package.json +171 -170
- package/src/entrypoints/sdk/coreTypes.generated.ts +2355 -2355
- package/src/entrypoints/sdk.d.ts +555 -555
package/bin/import-specifier.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { join, win32 } from 'path'
|
|
2
|
-
import { pathToFileURL } from 'url'
|
|
3
|
-
|
|
4
|
-
export function getDistImportSpecifier(baseDir) {
|
|
5
|
-
if (/^[A-Za-z]:\\/.test(baseDir)) {
|
|
6
|
-
const distPath = win32.join(baseDir, '..', 'dist', 'cli.mjs')
|
|
7
|
-
return `file:///${distPath.replace(/\\/g, '/')}`
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const joinImpl = join
|
|
11
|
-
const distPath = joinImpl(baseDir, '..', 'dist', 'cli.mjs')
|
|
12
|
-
return pathToFileURL(distPath).href
|
|
13
|
-
}
|
|
1
|
+
import { join, win32 } from 'path'
|
|
2
|
+
import { pathToFileURL } from 'url'
|
|
3
|
+
|
|
4
|
+
export function getDistImportSpecifier(baseDir) {
|
|
5
|
+
if (/^[A-Za-z]:\\/.test(baseDir)) {
|
|
6
|
+
const distPath = win32.join(baseDir, '..', 'dist', 'cli.mjs')
|
|
7
|
+
return `file:///${distPath.replace(/\\/g, '/')}`
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const joinImpl = join
|
|
11
|
+
const distPath = joinImpl(baseDir, '..', 'dist', 'cli.mjs')
|
|
12
|
+
return pathToFileURL(distPath).href
|
|
13
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test from 'node:test'
|
|
3
|
-
|
|
4
|
-
import { getDistImportSpecifier } from './import-specifier.mjs'
|
|
5
|
-
|
|
6
|
-
test('builds a file URL import specifier for dist/cli.mjs', () => {
|
|
7
|
-
const specifier = getDistImportSpecifier('C:\\repo\\bin')
|
|
8
|
-
|
|
9
|
-
assert.equal(
|
|
10
|
-
specifier,
|
|
11
|
-
'file:///C:/repo/dist/cli.mjs',
|
|
12
|
-
)
|
|
13
|
-
})
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import test from 'node:test'
|
|
3
|
+
|
|
4
|
+
import { getDistImportSpecifier } from './import-specifier.mjs'
|
|
5
|
+
|
|
6
|
+
test('builds a file URL import specifier for dist/cli.mjs', () => {
|
|
7
|
+
const specifier = getDistImportSpecifier('C:\\repo\\bin')
|
|
8
|
+
|
|
9
|
+
assert.equal(
|
|
10
|
+
specifier,
|
|
11
|
+
'file:///C:/repo/dist/cli.mjs',
|
|
12
|
+
)
|
|
13
|
+
})
|
package/bin/openclaude
CHANGED
|
@@ -1,32 +1,97 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* OpenClaude — Claude Code with any LLM
|
|
5
|
-
*
|
|
6
|
-
* If dist/cli.mjs exists (built), run that.
|
|
7
|
-
* Otherwise, tell the user to build first or use `bun run dev`.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { existsSync } from 'fs'
|
|
11
|
-
import { join, dirname } from 'path'
|
|
12
|
-
import { fileURLToPath, pathToFileURL } from 'url'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OpenClaude — Claude Code with any LLM
|
|
5
|
+
*
|
|
6
|
+
* If dist/cli.mjs exists (built), run that.
|
|
7
|
+
* Otherwise, tell the user to build first or use `bun run dev`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'fs'
|
|
11
|
+
import { join, dirname } from 'path'
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
13
|
+
import { spawnSync } from 'child_process'
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
const distPath = join(__dirname, '..', 'dist', 'cli.mjs')
|
|
17
|
+
|
|
18
|
+
const HEAP_RELAUNCHED_ENV = 'OPENCLAUDE_HEAP_RELAUNCHED'
|
|
19
|
+
const DISABLE_HEAP_RELAUNCH_ENV = 'OPENCLAUDE_DISABLE_HEAP_RELAUNCH'
|
|
20
|
+
const HEAP_SIZE_ENV = 'OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB'
|
|
21
|
+
const DEFAULT_HEAP_SIZE_MB = 8192
|
|
22
|
+
|
|
23
|
+
function hasNodeFlag(args, flag) {
|
|
24
|
+
return args.some(arg => arg === flag || arg.startsWith(`${flag}=`))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function hasNodeOptionFlag(flag) {
|
|
28
|
+
return hasNodeFlag([
|
|
29
|
+
...process.execArgv,
|
|
30
|
+
...(process.env.NODE_OPTIONS || '').split(/\s+/).filter(Boolean),
|
|
31
|
+
], flag)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getHeapSizeMb() {
|
|
35
|
+
const raw = process.env[HEAP_SIZE_ENV]
|
|
36
|
+
if (!raw) return DEFAULT_HEAP_SIZE_MB
|
|
37
|
+
const parsed = Number.parseInt(raw, 10)
|
|
38
|
+
return Number.isSafeInteger(parsed) && parsed > 0
|
|
39
|
+
? parsed
|
|
40
|
+
: DEFAULT_HEAP_SIZE_MB
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function relaunchWithLongSessionHeapIfNeeded() {
|
|
44
|
+
if (process.env[DISABLE_HEAP_RELAUNCH_ENV] === '1') return
|
|
45
|
+
if (process.env[HEAP_RELAUNCHED_ENV] === '1') return
|
|
46
|
+
const hasHeapLimit = hasNodeOptionFlag('--max-old-space-size')
|
|
47
|
+
const hasExplicitGc = hasNodeOptionFlag('--expose-gc')
|
|
48
|
+
if (hasHeapLimit && hasExplicitGc) return
|
|
49
|
+
|
|
50
|
+
const execArgv = [...process.execArgv]
|
|
51
|
+
if (!hasHeapLimit) {
|
|
52
|
+
execArgv.push(`--max-old-space-size=${getHeapSizeMb()}`)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Expose explicit GC for long interactive sessions. NODE_OPTIONS cannot
|
|
56
|
+
// carry --expose-gc, so the executable wrapper must add it before startup.
|
|
57
|
+
if (!hasExplicitGc) {
|
|
58
|
+
execArgv.push('--expose-gc')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = spawnSync(process.execPath, [
|
|
62
|
+
...execArgv,
|
|
63
|
+
fileURLToPath(import.meta.url),
|
|
64
|
+
...process.argv.slice(2),
|
|
65
|
+
], {
|
|
66
|
+
stdio: 'inherit',
|
|
67
|
+
env: {
|
|
68
|
+
...process.env,
|
|
69
|
+
[HEAP_RELAUNCHED_ENV]: '1',
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
if (result.error) {
|
|
74
|
+
console.error(`openclaude: failed to restart with long-session heap: ${result.error.message}`)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
process.exit(result.status ?? 1)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (existsSync(distPath)) {
|
|
82
|
+
relaunchWithLongSessionHeapIfNeeded()
|
|
83
|
+
await import(pathToFileURL(distPath).href)
|
|
84
|
+
} else {
|
|
85
|
+
console.error(`
|
|
86
|
+
openclaude: dist/cli.mjs not found.
|
|
87
|
+
|
|
88
|
+
Build first:
|
|
89
|
+
bun run build
|
|
90
|
+
|
|
91
|
+
Or run directly with Bun:
|
|
92
|
+
bun run dev
|
|
93
|
+
|
|
94
|
+
See README.md for setup instructions.
|
|
95
|
+
`)
|
|
96
|
+
process.exit(1)
|
|
97
|
+
}
|