gclm-code 1.0.0 → 1.0.1

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 (43) hide show
  1. package/README.md +1 -1
  2. package/bin/gc.js +53 -25
  3. package/bin/install-runtime.js +253 -0
  4. package/package.json +10 -5
  5. package/vendor/manifest.json +92 -0
  6. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/package.json +9 -0
  7. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/bridgeClient.ts +1126 -0
  8. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/browserTools.ts +546 -0
  9. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/index.ts +15 -0
  10. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/mcpServer.ts +96 -0
  11. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/mcpSocketClient.ts +493 -0
  12. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/mcpSocketPool.ts +327 -0
  13. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/toolCalls.ts +301 -0
  14. package/vendor/modules/node_modules/@ant/claude-for-chrome-mcp/src/types.ts +134 -0
  15. package/vendor/modules/node_modules/@ant/computer-use-input/package.json +9 -0
  16. package/vendor/modules/node_modules/@ant/computer-use-input/src/driver-jxa.js +341 -0
  17. package/vendor/modules/node_modules/@ant/computer-use-input/src/driver-swift.swift +417 -0
  18. package/vendor/modules/node_modules/@ant/computer-use-input/src/implementation.js +204 -0
  19. package/vendor/modules/node_modules/@ant/computer-use-input/src/index.js +5 -0
  20. package/vendor/modules/node_modules/@ant/computer-use-mcp/package.json +11 -0
  21. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/deniedApps.ts +553 -0
  22. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/imageResize.ts +108 -0
  23. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/index.ts +69 -0
  24. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/keyBlocklist.ts +153 -0
  25. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/mcpServer.ts +313 -0
  26. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/pixelCompare.ts +171 -0
  27. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/sentinelApps.ts +43 -0
  28. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/subGates.ts +19 -0
  29. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/toolCalls.ts +3872 -0
  30. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/tools.ts +706 -0
  31. package/vendor/modules/node_modules/@ant/computer-use-mcp/src/types.ts +635 -0
  32. package/vendor/modules/node_modules/@ant/computer-use-swift/package.json +9 -0
  33. package/vendor/modules/node_modules/@ant/computer-use-swift/src/driver-jxa.js +108 -0
  34. package/vendor/modules/node_modules/@ant/computer-use-swift/src/implementation.js +706 -0
  35. package/vendor/modules/node_modules/@ant/computer-use-swift/src/index.js +7 -0
  36. package/vendor/modules/node_modules/audio-capture-napi/package.json +8 -0
  37. package/vendor/modules/node_modules/audio-capture-napi/src/index.ts +226 -0
  38. package/vendor/modules/node_modules/image-processor-napi/package.json +11 -0
  39. package/vendor/modules/node_modules/image-processor-napi/src/index.ts +396 -0
  40. package/vendor/modules/node_modules/modifiers-napi/package.json +8 -0
  41. package/vendor/modules/node_modules/modifiers-napi/src/index.ts +79 -0
  42. package/vendor/modules/node_modules/url-handler-napi/package.json +8 -0
  43. package/vendor/modules/node_modules/url-handler-napi/src/index.ts +62 -0
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # gclm-code
2
2
 
3
- Generated binary launcher package.
3
+ Generated single-package staging for Gclm Code 1.0.1.
package/bin/gc.js CHANGED
@@ -1,50 +1,78 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from 'node:child_process'
3
- import { existsSync } from 'node:fs'
4
- import { createRequire } from 'node:module'
5
- import { dirname, join } from 'node:path'
6
-
7
- const require = createRequire(import.meta.url)
8
- const packageMap = {
9
- "darwin": {
10
- "x64": "gclm-code-darwin-x64",
11
- "arm64": "gclm-code-darwin-arm64"
12
- }
13
- }
3
+ import { existsSync, readFileSync } from 'node:fs'
4
+ import { delimiter, dirname, join } from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+
7
+ const packageDir = dirname(dirname(fileURLToPath(import.meta.url)))
8
+ const manifestPath = join(packageDir, 'vendor', 'manifest.json')
14
9
 
15
10
  function fail(message) {
16
11
  process.stderr.write(`[gclm-code] ${message}\n`)
17
12
  process.exit(1)
18
13
  }
19
14
 
20
- const osPackageMap = packageMap[process.platform]
21
- if (!osPackageMap) {
22
- fail(`当前暂不支持平台: ${process.platform}`)
15
+ function readManifest() {
16
+ let raw
17
+ try {
18
+ raw = readFileSync(manifestPath, 'utf8')
19
+ } catch (error) {
20
+ fail(`缺少运行时清单: ${manifestPath} (${error.message})`)
21
+ }
22
+
23
+ try {
24
+ return JSON.parse(raw)
25
+ } catch (error) {
26
+ fail(`运行时清单解析失败: ${manifestPath} (${error.message})`)
27
+ }
23
28
  }
24
29
 
25
- const packageName = osPackageMap[process.arch]
26
- if (!packageName) {
27
- fail(`当前暂不支持平台组合: ${process.platform}/${process.arch}`)
30
+ const manifest = readManifest()
31
+ const platformId = `${process.platform}-${process.arch}`
32
+ const platformEntry = manifest?.runtime?.platforms?.[platformId]
33
+
34
+ if (!platformEntry) {
35
+ fail(`当前暂不支持平台组合: ${platformId}`)
28
36
  }
29
37
 
30
- let packageJsonPath
31
- try {
32
- packageJsonPath = require.resolve(`${packageName}/package.json`)
33
- } catch {
34
- fail(`未找到匹配架构包 ${packageName},请重新安装 gclm-code`)
38
+ if (
39
+ typeof platformEntry.installSubpath !== 'string' ||
40
+ platformEntry.installSubpath.length === 0
41
+ ) {
42
+ fail(`运行时清单缺少 installSubpath: ${platformId}`)
35
43
  }
36
44
 
37
- const binaryPath = join(dirname(packageJsonPath), 'bin', 'gc')
45
+ const binaryPath = join(packageDir, platformEntry.installSubpath)
38
46
  if (!existsSync(binaryPath)) {
39
- fail(`${packageName} 缺少可执行文件: ${binaryPath}`)
47
+ const assetHint =
48
+ typeof platformEntry.assetName === 'string' && platformEntry.assetName.length > 0
49
+ ? `;预期资产: ${platformEntry.assetName}`
50
+ : ''
51
+
52
+ fail(
53
+ `当前平台 runtime 未就绪: ${binaryPath}${assetHint}。请重新安装 gclm-code,或运行 npm rebuild gclm-code 重新触发 runtime 安装`,
54
+ )
55
+ }
56
+
57
+ const moduleNodePath =
58
+ typeof manifest?.modules?.nodePath === 'string' && manifest.modules.nodePath.length > 0
59
+ ? join(packageDir, manifest.modules.nodePath)
60
+ : null
61
+
62
+ const childEnv = { ...process.env }
63
+ if (moduleNodePath && existsSync(moduleNodePath)) {
64
+ childEnv.NODE_PATH = childEnv.NODE_PATH
65
+ ? `${moduleNodePath}${delimiter}${childEnv.NODE_PATH}`
66
+ : moduleNodePath
40
67
  }
41
68
 
42
69
  const child = spawn(binaryPath, process.argv.slice(2), {
43
70
  stdio: 'inherit',
71
+ env: childEnv,
44
72
  })
45
73
 
46
74
  child.on('error', error => {
47
- fail(`启动 ${packageName} 失败: ${error.message}`)
75
+ fail(`启动 runtime 失败: ${error.message}`)
48
76
  })
49
77
 
50
78
  child.on('exit', (code, signal) => {
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ chmodSync,
4
+ copyFileSync,
5
+ existsSync,
6
+ mkdtempSync,
7
+ mkdirSync,
8
+ readFileSync,
9
+ rmSync,
10
+ symlinkSync,
11
+ writeFileSync,
12
+ } from 'node:fs'
13
+ import { createHash } from 'node:crypto'
14
+ import { spawnSync } from 'node:child_process'
15
+ import { tmpdir } from 'node:os'
16
+ import { dirname, join, relative, resolve } from 'node:path'
17
+ import { fileURLToPath } from 'node:url'
18
+
19
+ function fail(message) {
20
+ process.stderr.write(`[gclm-code] ${message}\n`)
21
+ process.exit(1)
22
+ }
23
+
24
+ function parseArgs(argv) {
25
+ const scriptPackageDir = dirname(dirname(fileURLToPath(import.meta.url)))
26
+ const options = {
27
+ packageDir: scriptPackageDir,
28
+ force: false,
29
+ }
30
+
31
+ for (let i = 0; i < argv.length; i += 1) {
32
+ const arg = argv[i]
33
+ if (arg === '--package-dir' && argv[i + 1]) {
34
+ options.packageDir = resolve(argv[i + 1])
35
+ i += 1
36
+ continue
37
+ }
38
+ if (arg === '--force') {
39
+ options.force = true
40
+ continue
41
+ }
42
+ throw new Error(`Unknown argument: ${arg}`)
43
+ }
44
+
45
+ return options
46
+ }
47
+
48
+ function readManifest(packageDir) {
49
+ const manifestPath = join(packageDir, 'vendor', 'manifest.json')
50
+ let raw
51
+ try {
52
+ raw = readFileSync(manifestPath, 'utf8')
53
+ } catch (error) {
54
+ fail(`读取运行时清单失败: ${manifestPath} (${error.message})`)
55
+ }
56
+
57
+ try {
58
+ return {
59
+ manifestPath,
60
+ value: JSON.parse(raw),
61
+ }
62
+ } catch (error) {
63
+ fail(`运行时清单解析失败: ${manifestPath} (${error.message})`)
64
+ }
65
+ }
66
+
67
+ function resolveBaseUrl(manifest, packageDir) {
68
+ const envName = manifest?.runtime?.baseUrlEnv
69
+ const envBaseUrl =
70
+ typeof envName === 'string' && envName.length > 0
71
+ ? process.env[envName]
72
+ : undefined
73
+
74
+ const baseUrl =
75
+ typeof envBaseUrl === 'string' && envBaseUrl.length > 0
76
+ ? envBaseUrl
77
+ : manifest?.runtime?.baseUrl
78
+
79
+ if (typeof baseUrl !== 'string' || baseUrl.length === 0) {
80
+ fail(
81
+ `缺少 runtime 来源地址,请设置 ${envName ?? 'GCLM_BINARY_BASE_URL'} 或在 vendor/manifest.json 中提供 runtime.baseUrl`,
82
+ )
83
+ }
84
+
85
+ if (baseUrl.startsWith('file://')) {
86
+ return {
87
+ type: 'file',
88
+ value: fileURLToPath(baseUrl),
89
+ }
90
+ }
91
+
92
+ if (baseUrl.startsWith('http://') || baseUrl.startsWith('https://')) {
93
+ return {
94
+ type: 'http',
95
+ value: baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`,
96
+ }
97
+ }
98
+
99
+ return {
100
+ type: 'file',
101
+ value: resolve(packageDir, baseUrl),
102
+ }
103
+ }
104
+
105
+ async function fetchHttp(url) {
106
+ const response = await fetch(url)
107
+ if (!response.ok) {
108
+ throw new Error(`HTTP ${response.status} ${response.statusText}`)
109
+ }
110
+ const arrayBuffer = await response.arrayBuffer()
111
+ return Buffer.from(arrayBuffer)
112
+ }
113
+
114
+ async function readAsset(assetSource, fileName) {
115
+ if (assetSource.type === 'http') {
116
+ const targetUrl = new URL(fileName, assetSource.value).toString()
117
+ return {
118
+ location: targetUrl,
119
+ content: await fetchHttp(targetUrl),
120
+ }
121
+ }
122
+
123
+ const targetPath = join(assetSource.value, fileName)
124
+ return {
125
+ location: targetPath,
126
+ content: readFileSync(targetPath),
127
+ }
128
+ }
129
+
130
+ function parseChecksumFile(content) {
131
+ const text = content.toString('utf8').trim()
132
+ const [hash] = text.split(/\s+/)
133
+ if (!hash) {
134
+ throw new Error('checksum 文件为空')
135
+ }
136
+ return hash
137
+ }
138
+
139
+ function sha256(buffer) {
140
+ return createHash('sha256').update(buffer).digest('hex')
141
+ }
142
+
143
+ function run(command, args, options = {}) {
144
+ const result = spawnSync(command, args, {
145
+ cwd: options.cwd,
146
+ encoding: 'utf8',
147
+ stdio: 'pipe',
148
+ })
149
+
150
+ if (result.status !== 0) {
151
+ const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim()
152
+ throw new Error(output || `${command} failed`)
153
+ }
154
+ }
155
+
156
+ const options = parseArgs(process.argv.slice(2))
157
+ const { value: manifest } = readManifest(options.packageDir)
158
+ const platformId = `${process.platform}-${process.arch}`
159
+ const platformEntry = manifest?.runtime?.platforms?.[platformId]
160
+
161
+ if (!platformEntry) {
162
+ process.stdout.write(
163
+ `[gclm-code] SKIP runtime install - 当前暂不支持平台组合: ${platformId}\n`,
164
+ )
165
+ process.exit(0)
166
+ }
167
+
168
+ if (
169
+ typeof platformEntry.installSubpath !== 'string' ||
170
+ platformEntry.installSubpath.length === 0
171
+ ) {
172
+ fail(`运行时清单缺少 installSubpath: ${platformId}`)
173
+ }
174
+
175
+ if (
176
+ typeof platformEntry.archiveBinarySubpath !== 'string' ||
177
+ platformEntry.archiveBinarySubpath.length === 0
178
+ ) {
179
+ fail(`运行时清单缺少 archiveBinarySubpath: ${platformId}`)
180
+ }
181
+
182
+ const assetSource = resolveBaseUrl(manifest, options.packageDir)
183
+ const installPath = join(options.packageDir, platformEntry.installSubpath)
184
+ const installDir = dirname(installPath)
185
+ const tempDir = mkdtempSync(join(tmpdir(), 'gclm-runtime-install-'))
186
+ const moduleNodePath =
187
+ typeof manifest?.modules?.nodePath === 'string' && manifest.modules.nodePath.length > 0
188
+ ? join(options.packageDir, manifest.modules.nodePath)
189
+ : null
190
+
191
+ try {
192
+ const assetName = platformEntry.assetName
193
+ const checksumAssetName = platformEntry.checksumAssetName
194
+ if (typeof assetName !== 'string' || assetName.length === 0) {
195
+ fail(`运行时清单缺少 assetName: ${platformId}`)
196
+ }
197
+ if (
198
+ typeof checksumAssetName !== 'string' ||
199
+ checksumAssetName.length === 0
200
+ ) {
201
+ fail(`运行时清单缺少 checksumAssetName: ${platformId}`)
202
+ }
203
+
204
+ const [{ location: assetLocation, content: archiveContent }, { content: checksumContent }] =
205
+ await Promise.all([
206
+ readAsset(assetSource, assetName),
207
+ readAsset(assetSource, checksumAssetName),
208
+ ])
209
+
210
+ const expectedSha = parseChecksumFile(checksumContent)
211
+ const actualSha = sha256(archiveContent)
212
+ if (expectedSha !== actualSha) {
213
+ fail(
214
+ `runtime sha256 校验失败: ${assetName} expected=${expectedSha} actual=${actualSha}`,
215
+ )
216
+ }
217
+
218
+ const archivePath = join(tempDir, assetName)
219
+ const extractDir = join(tempDir, 'extract')
220
+ mkdirSync(extractDir, { recursive: true })
221
+ writeFileSync(archivePath, archiveContent)
222
+
223
+ run('tar', [
224
+ '-xzf',
225
+ archivePath,
226
+ '-C',
227
+ extractDir,
228
+ platformEntry.archiveBinarySubpath,
229
+ ])
230
+
231
+ const extractedBinaryPath = join(extractDir, platformEntry.archiveBinarySubpath)
232
+ mkdirSync(installDir, { recursive: true })
233
+ copyFileSync(extractedBinaryPath, installPath)
234
+ chmodSync(installPath, 0o755)
235
+
236
+ if (moduleNodePath && existsSync(moduleNodePath)) {
237
+ const runtimeNodeModulesPath = join(installDir, 'node_modules')
238
+ rmSync(runtimeNodeModulesPath, { recursive: true, force: true })
239
+ symlinkSync(relative(installDir, moduleNodePath), runtimeNodeModulesPath, 'dir')
240
+ }
241
+
242
+ process.stdout.write(
243
+ `[gclm-code] runtime 已安装: ${platformId} <- ${assetLocation}\n`,
244
+ )
245
+ } catch (error) {
246
+ const detail = error instanceof Error ? error.message : String(error)
247
+ fail(`安装当前平台 runtime 失败: ${detail}`)
248
+ } finally {
249
+ if (options.force) {
250
+ // Placeholder to keep CLI stable if future force-specific cleanup is needed.
251
+ }
252
+ rmSync(tempDir, { recursive: true, force: true })
253
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "gclm-code",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
- "description": "Binary launcher package for Gclm Code.",
5
+ "description": "Single-package runtime launcher for Gclm Code.",
6
6
  "type": "module",
7
7
  "license": "UNLICENSED",
8
8
  "os": [
@@ -16,12 +16,17 @@
16
16
  "gc": "./bin/gc.js",
17
17
  "claude": "./bin/gc.js"
18
18
  },
19
- "optionalDependencies": {
20
- "gclm-code-darwin-x64": "1.0.0",
21
- "gclm-code-darwin-arm64": "1.0.0"
19
+ "scripts": {
20
+ "postinstall": "node ./bin/install-runtime.js"
21
+ },
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.29.0",
24
+ "sharp": "^0.34.5",
25
+ "ws": "^8.20.0"
22
26
  },
23
27
  "files": [
24
28
  "bin",
29
+ "vendor",
25
30
  "README.md"
26
31
  ]
27
32
  }
@@ -0,0 +1,92 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "packageName": "gclm-code",
4
+ "version": "1.0.1",
5
+ "generatedAt": "2026-04-05T14:40:23.857Z",
6
+ "releaseTag": "v1.0.1",
7
+ "runtime": {
8
+ "baseUrl": "https://github.com/gclm/gclm-code/releases/download/v1.0.1/",
9
+ "baseUrlEnv": "GCLM_BINARY_BASE_URL",
10
+ "platforms": {
11
+ "darwin-x64": {
12
+ "os": "darwin",
13
+ "arch": "x64",
14
+ "releaseLabel": "darwin-x64",
15
+ "binaryArtifact": "gc-darwin-x64",
16
+ "installSubpath": "vendor/runtime/darwin-x64/gc",
17
+ "assetName": "gclm-code-1.0.1-darwin-x64.tar.gz",
18
+ "checksumAssetName": "gclm-code-1.0.1-darwin-x64.tar.gz.sha256",
19
+ "archiveBinarySubpath": "bin/gc"
20
+ },
21
+ "darwin-arm64": {
22
+ "os": "darwin",
23
+ "arch": "arm64",
24
+ "releaseLabel": "darwin-arm64",
25
+ "binaryArtifact": "gc-darwin-arm64",
26
+ "installSubpath": "vendor/runtime/darwin-arm64/gc",
27
+ "assetName": "gclm-code-1.0.1-darwin-arm64.tar.gz",
28
+ "checksumAssetName": "gclm-code-1.0.1-darwin-arm64.tar.gz.sha256",
29
+ "archiveBinarySubpath": "bin/gc"
30
+ }
31
+ }
32
+ },
33
+ "modules": {
34
+ "nodePath": "vendor/modules/node_modules",
35
+ "workspacePackages": {
36
+ "audio-capture-napi": {
37
+ "sourceSubpath": "packages/audio-capture-napi",
38
+ "installSubpath": "vendor/modules/node_modules/audio-capture-napi",
39
+ "runtimeDependencies": []
40
+ },
41
+ "image-processor-napi": {
42
+ "sourceSubpath": "packages/image-processor-napi",
43
+ "installSubpath": "vendor/modules/node_modules/image-processor-napi",
44
+ "runtimeDependencies": [
45
+ "sharp"
46
+ ]
47
+ },
48
+ "modifiers-napi": {
49
+ "sourceSubpath": "packages/modifiers-napi",
50
+ "installSubpath": "vendor/modules/node_modules/modifiers-napi",
51
+ "runtimeDependencies": []
52
+ },
53
+ "url-handler-napi": {
54
+ "sourceSubpath": "packages/url-handler-napi",
55
+ "installSubpath": "vendor/modules/node_modules/url-handler-napi",
56
+ "runtimeDependencies": []
57
+ },
58
+ "@ant/claude-for-chrome-mcp": {
59
+ "sourceSubpath": "packages/claude-for-chrome-mcp",
60
+ "installSubpath": "vendor/modules/node_modules/@ant/claude-for-chrome-mcp",
61
+ "runtimeDependencies": [
62
+ "@modelcontextprotocol/sdk",
63
+ "ws"
64
+ ]
65
+ },
66
+ "@ant/computer-use-input": {
67
+ "sourceSubpath": "packages/computer-use-input",
68
+ "installSubpath": "vendor/modules/node_modules/@ant/computer-use-input",
69
+ "runtimeDependencies": []
70
+ },
71
+ "@ant/computer-use-mcp": {
72
+ "sourceSubpath": "packages/computer-use-mcp",
73
+ "installSubpath": "vendor/modules/node_modules/@ant/computer-use-mcp",
74
+ "runtimeDependencies": [
75
+ "@modelcontextprotocol/sdk"
76
+ ]
77
+ },
78
+ "@ant/computer-use-swift": {
79
+ "sourceSubpath": "packages/computer-use",
80
+ "installSubpath": "vendor/modules/node_modules/@ant/computer-use-swift",
81
+ "runtimeDependencies": [
82
+ "sharp"
83
+ ]
84
+ }
85
+ },
86
+ "externalDependencies": {
87
+ "@modelcontextprotocol/sdk": "^1.29.0",
88
+ "sharp": "^0.34.5",
89
+ "ws": "^8.20.0"
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@ant/claude-for-chrome-mcp",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts"
8
+ }
9
+ }