@deleted-ai/deleted 0.1.272
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/README.md +37 -0
- package/THIRD_PARTY_NOTICES +1548 -0
- package/bin/deleted.js +26 -0
- package/bundled/linux-arm64.tar.gz +0 -0
- package/lib/install.js +199 -0
- package/lib/manifest.js +26 -0
- package/lib/paths.js +30 -0
- package/lib/platform.js +25 -0
- package/lib/postinstall.js +14 -0
- package/package.json +33 -0
- package/release-manifest.json +8 -0
package/bin/deleted.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { ensureInstalled } from '../lib/install.js';
|
|
5
|
+
import { nativeBinaryPath } from '../lib/paths.js';
|
|
6
|
+
|
|
7
|
+
let cacheDir;
|
|
8
|
+
try {
|
|
9
|
+
cacheDir = ensureInstalled();
|
|
10
|
+
} catch (err) {
|
|
11
|
+
console.error(String(err));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const binary = nativeBinaryPath(cacheDir);
|
|
16
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
env: process.env,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (result.error) {
|
|
22
|
+
console.error(result.error.message);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
process.exit(result.status ?? 1);
|
|
Binary file
|
package/lib/install.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { assertSupportedPlatform } from './platform.js';
|
|
7
|
+
import { readManifest, releaseDownloadUrl, tarballFileName } from './manifest.js';
|
|
8
|
+
import {
|
|
9
|
+
cacheRoot,
|
|
10
|
+
isInstalled,
|
|
11
|
+
nativeBinaryPath,
|
|
12
|
+
packageRoot,
|
|
13
|
+
} from './paths.js';
|
|
14
|
+
|
|
15
|
+
const ZERO_SHA256 =
|
|
16
|
+
'0000000000000000000000000000000000000000000000000000000000000000';
|
|
17
|
+
|
|
18
|
+
function copyTree(src, dest) {
|
|
19
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
20
|
+
fs.cpSync(src, dest, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function verifyTarballSha256(tarballPath, manifest) {
|
|
24
|
+
const expected = manifest.tarballSha256;
|
|
25
|
+
if (!expected || expected === ZERO_SHA256) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const hash = crypto
|
|
29
|
+
.createHash('sha256')
|
|
30
|
+
.update(fs.readFileSync(tarballPath))
|
|
31
|
+
.digest('hex');
|
|
32
|
+
if (hash !== expected) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`tarball SHA-256 mismatch for ${path.basename(tarballPath)}`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function extractTarball(tarballPath, destDir) {
|
|
40
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
41
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'deleted-npm-'));
|
|
42
|
+
try {
|
|
43
|
+
execFileSync('tar', ['-xzf', tarballPath, '-C', tmp], { stdio: 'inherit' });
|
|
44
|
+
const entries = fs.readdirSync(tmp);
|
|
45
|
+
const root =
|
|
46
|
+
entries.length === 1 ? path.join(tmp, entries[0]) : tmp;
|
|
47
|
+
copyTree(root, destDir);
|
|
48
|
+
} finally {
|
|
49
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function stageFromDirectory(stagingDir, destDir) {
|
|
54
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
55
|
+
copyTree(stagingDir, destDir);
|
|
56
|
+
fs.chmodSync(nativeBinaryPath(destDir), 0o755);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function downloadRelease(url, destFile) {
|
|
60
|
+
execFileSync(
|
|
61
|
+
'curl',
|
|
62
|
+
['-fsSL', '--retry', '3', '--retry-delay', '2', '-o', destFile, url],
|
|
63
|
+
{ stdio: 'inherit' },
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function installFromTarball(tarballPath, manifest, destDir) {
|
|
68
|
+
verifyTarballSha256(tarballPath, manifest);
|
|
69
|
+
extractTarball(tarballPath, destDir);
|
|
70
|
+
fs.chmodSync(nativeBinaryPath(destDir), 0o755);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function resolveLocalTarball(manifest) {
|
|
74
|
+
if (process.env.DELETED_RELEASE_TARBALL) {
|
|
75
|
+
const p = path.resolve(process.env.DELETED_RELEASE_TARBALL);
|
|
76
|
+
if (!fs.existsSync(p)) {
|
|
77
|
+
throw new Error(`DELETED_RELEASE_TARBALL not found: ${p}`);
|
|
78
|
+
}
|
|
79
|
+
return p;
|
|
80
|
+
}
|
|
81
|
+
const bundled = path.join(packageRoot(), 'bundled', 'linux-arm64.tar.gz');
|
|
82
|
+
if (fs.existsSync(bundled)) {
|
|
83
|
+
return bundled;
|
|
84
|
+
}
|
|
85
|
+
const local = path.join(
|
|
86
|
+
packageRoot(),
|
|
87
|
+
'..',
|
|
88
|
+
'..',
|
|
89
|
+
'target',
|
|
90
|
+
'deleted-release',
|
|
91
|
+
tarballFileName(manifest),
|
|
92
|
+
);
|
|
93
|
+
if (fs.existsSync(local)) {
|
|
94
|
+
return local;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function resolveLocalStagingDir() {
|
|
100
|
+
if (process.env.DELETED_RELEASE_DIR) {
|
|
101
|
+
const p = path.resolve(process.env.DELETED_RELEASE_DIR);
|
|
102
|
+
if (!fs.existsSync(p)) {
|
|
103
|
+
throw new Error(`DELETED_RELEASE_DIR not found: ${p}`);
|
|
104
|
+
}
|
|
105
|
+
return p;
|
|
106
|
+
}
|
|
107
|
+
const local = path.join(
|
|
108
|
+
packageRoot(),
|
|
109
|
+
'..',
|
|
110
|
+
'..',
|
|
111
|
+
'target',
|
|
112
|
+
'deleted-release',
|
|
113
|
+
'deleted-linux-arm64',
|
|
114
|
+
);
|
|
115
|
+
if (fs.existsSync(path.join(local, 'bin', 'deleted'))) {
|
|
116
|
+
return local;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function installFromRelease(manifest, destDir) {
|
|
122
|
+
const staging = resolveLocalStagingDir();
|
|
123
|
+
if (staging) {
|
|
124
|
+
stageFromDirectory(staging, destDir);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const localTarball = resolveLocalTarball(manifest);
|
|
129
|
+
if (localTarball) {
|
|
130
|
+
installFromTarball(localTarball, manifest, destDir);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const url = releaseDownloadUrl(manifest);
|
|
135
|
+
if (!manifest.tarballSha256 || manifest.tarballSha256 === ZERO_SHA256) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
'release-manifest.json missing tarballSha256; cannot download unverified binary',
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const token = process.env.DELETED_GITHUB_TOKEN || process.env.GITHUB_TOKEN;
|
|
142
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'deleted-npm-dl-'));
|
|
143
|
+
const tmpTarball = path.join(tmpDir, tarballFileName(manifest));
|
|
144
|
+
try {
|
|
145
|
+
if (token) {
|
|
146
|
+
execFileSync(
|
|
147
|
+
'curl',
|
|
148
|
+
[
|
|
149
|
+
'-fsSL',
|
|
150
|
+
'--retry',
|
|
151
|
+
'3',
|
|
152
|
+
'--retry-delay',
|
|
153
|
+
'2',
|
|
154
|
+
'-H',
|
|
155
|
+
`Authorization: Bearer ${token}`,
|
|
156
|
+
'-o',
|
|
157
|
+
tmpTarball,
|
|
158
|
+
url,
|
|
159
|
+
],
|
|
160
|
+
{ stdio: 'inherit' },
|
|
161
|
+
);
|
|
162
|
+
} else {
|
|
163
|
+
downloadRelease(url, tmpTarball);
|
|
164
|
+
}
|
|
165
|
+
installFromTarball(tmpTarball, manifest, destDir);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
const hint = [
|
|
168
|
+
'Could not download the Deleted AI linux-arm64 release binary.',
|
|
169
|
+
`URL: ${url}`,
|
|
170
|
+
'',
|
|
171
|
+
'Published npm packages ship bundled/linux-arm64.tar.gz for anonymous install.',
|
|
172
|
+
'For CI or monorepo dev, set DELETED_RELEASE_TARBALL or DELETED_RELEASE_DIR.',
|
|
173
|
+
`Optional GitHub auth: DELETED_GITHUB_TOKEN (private release assets).`,
|
|
174
|
+
'',
|
|
175
|
+
String(err),
|
|
176
|
+
].join('\n');
|
|
177
|
+
throw new Error(hint);
|
|
178
|
+
} finally {
|
|
179
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Ensure native binary + share/ tree are cached. Returns cache directory. */
|
|
184
|
+
export function ensureInstalled() {
|
|
185
|
+
assertSupportedPlatform();
|
|
186
|
+
const manifest = readManifest();
|
|
187
|
+
const destDir = cacheRoot(manifest.version);
|
|
188
|
+
if (isInstalled(destDir)) {
|
|
189
|
+
return destDir;
|
|
190
|
+
}
|
|
191
|
+
fs.mkdirSync(path.dirname(destDir), { recursive: true });
|
|
192
|
+
installFromRelease(manifest, destDir);
|
|
193
|
+
if (!isInstalled(destDir)) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`install incomplete: expected ${nativeBinaryPath(destDir)} and starter harness`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
return destDir;
|
|
199
|
+
}
|
package/lib/manifest.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { packageRoot } from './paths.js';
|
|
4
|
+
|
|
5
|
+
/** @typedef {{ version: string; gitSha: string; repo: string; tarballPrefix: string; releaseTagPrefix: string }} ReleaseManifest */
|
|
6
|
+
|
|
7
|
+
/** @returns {ReleaseManifest} */
|
|
8
|
+
export function readManifest() {
|
|
9
|
+
const raw = fs.readFileSync(
|
|
10
|
+
path.join(packageRoot(), 'release-manifest.json'),
|
|
11
|
+
'utf8',
|
|
12
|
+
);
|
|
13
|
+
return JSON.parse(raw);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @param {ReleaseManifest} manifest */
|
|
17
|
+
export function tarballFileName(manifest) {
|
|
18
|
+
return `${manifest.tarballPrefix}-${manifest.gitSha}.tar.gz`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @param {ReleaseManifest} manifest */
|
|
22
|
+
export function releaseDownloadUrl(manifest) {
|
|
23
|
+
const tag = `${manifest.releaseTagPrefix}${manifest.version}`;
|
|
24
|
+
const file = tarballFileName(manifest);
|
|
25
|
+
return `https://github.com/${manifest.repo}/releases/download/${tag}/${file}`;
|
|
26
|
+
}
|
package/lib/paths.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
export function packageRoot() {
|
|
9
|
+
return path.join(moduleDir, '..');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @param {string} version npm package / release version */
|
|
13
|
+
export function cacheRoot(version) {
|
|
14
|
+
const base =
|
|
15
|
+
process.env.DELETED_CACHE_DIR ||
|
|
16
|
+
path.join(os.homedir(), '.cache', 'deleted-ai');
|
|
17
|
+
return path.join(base, version);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @param {string} cacheDir */
|
|
21
|
+
export function nativeBinaryPath(cacheDir) {
|
|
22
|
+
return path.join(cacheDir, 'bin', 'deleted');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @param {string} cacheDir */
|
|
26
|
+
export function isInstalled(cacheDir) {
|
|
27
|
+
const binary = nativeBinaryPath(cacheDir);
|
|
28
|
+
const starter = path.join(cacheDir, 'share', 'starter', 'chat-echo', 'deployment.lock');
|
|
29
|
+
return fs.existsSync(binary) && fs.existsSync(starter);
|
|
30
|
+
}
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @returns {{ supported: boolean; platform: string; arch: string }} */
|
|
2
|
+
export function platformInfo() {
|
|
3
|
+
return {
|
|
4
|
+
supported: process.platform === 'linux' && process.arch === 'arm64',
|
|
5
|
+
platform: process.platform,
|
|
6
|
+
arch: process.arch,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function unsupportedPlatformMessage() {
|
|
11
|
+
const { platform, arch } = platformInfo();
|
|
12
|
+
return [
|
|
13
|
+
'@deleted-ai/deleted: Linux arm64 only (Deleted AI v0 support floor).',
|
|
14
|
+
`Your platform: ${platform} ${arch}.`,
|
|
15
|
+
'Deferred platforms (macOS, Windows, linux-x64): use the tarball from',
|
|
16
|
+
'https://github.com/cdlconsultants/deleted-ai/blob/main/docs/install-deleted.md',
|
|
17
|
+
].join('\n');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function assertSupportedPlatform() {
|
|
21
|
+
if (!platformInfo().supported) {
|
|
22
|
+
console.error(unsupportedPlatformMessage());
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { platformInfo, unsupportedPlatformMessage } from './platform.js';
|
|
2
|
+
import { ensureInstalled } from './install.js';
|
|
3
|
+
|
|
4
|
+
if (!platformInfo().supported) {
|
|
5
|
+
console.error(unsupportedPlatformMessage());
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
ensureInstalled();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(String(err));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deleted-ai/deleted",
|
|
3
|
+
"version": "0.1.272",
|
|
4
|
+
"description": "Deleted AI CLI wrapper — downloads the linux-arm64 native binary on install",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": "^22.19 || >=24"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"deleted": "bin/deleted.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"lib",
|
|
20
|
+
"bundled",
|
|
21
|
+
"release-manifest.json",
|
|
22
|
+
"THIRD_PARTY_NOTICES",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"postinstall": "node lib/postinstall.js"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/cdlconsultants/deleted-ai.git",
|
|
31
|
+
"directory": "packages/deleted-npm"
|
|
32
|
+
}
|
|
33
|
+
}
|