@celljs/ta-harness 4.8.0 → 4.9.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.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/package-archive.d.ts +38 -0
- package/esm/node/package-archive.js +258 -0
- package/esm/node/serve-state.d.ts +8 -0
- package/esm/node/serve-state.js +36 -0
- package/esm/node/ta-cli.d.ts +2 -0
- package/esm/node/ta-cli.js +45 -4
- package/esm/node/ta-packages.d.ts +1 -0
- package/esm/node/ta-packages.js +15 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/node/package-archive.d.ts +39 -0
- package/lib/node/package-archive.js +261 -0
- package/lib/node/serve-state.d.ts +8 -0
- package/lib/node/serve-state.js +36 -0
- package/lib/node/ta-cli.d.ts +2 -0
- package/lib/node/ta-cli.js +45 -4
- package/lib/node/ta-packages.d.ts +1 -0
- package/lib/node/ta-packages.js +15 -1
- package/package.json +6 -5
- package/esm/node/brand-extension.js.map +0 -1
- package/esm/node/bug-report.js.map +0 -1
- package/esm/node/dino-logo.js.map +0 -1
- package/esm/node/exec-extension.js.map +0 -1
- package/esm/node/exec-mcp-transport.js.map +0 -1
- package/esm/node/exec-operations.js.map +0 -1
- package/esm/node/extensions.js.map +0 -1
- package/esm/node/glob-util.js.map +0 -1
- package/esm/node/index.js.map +0 -1
- package/esm/node/pi-types.js.map +0 -1
- package/esm/node/remote-context-files.js.map +0 -1
- package/esm/node/serve-state.js.map +0 -1
- package/esm/node/session-lock.js.map +0 -1
- package/esm/node/ta-brand.js.map +0 -1
- package/esm/node/ta-cli.js.map +0 -1
- package/esm/node/ta-header.js.map +0 -1
- package/esm/node/ta-packages.js.map +0 -1
- package/lib/node/brand-extension.d.ts.map +0 -1
- package/lib/node/brand-extension.js.map +0 -1
- package/lib/node/brand-extension.spec.d.ts +0 -2
- package/lib/node/brand-extension.spec.d.ts.map +0 -1
- package/lib/node/brand-extension.spec.js +0 -57
- package/lib/node/brand-extension.spec.js.map +0 -1
- package/lib/node/bug-report.d.ts.map +0 -1
- package/lib/node/bug-report.js.map +0 -1
- package/lib/node/bug-report.spec.d.ts +0 -2
- package/lib/node/bug-report.spec.d.ts.map +0 -1
- package/lib/node/bug-report.spec.js +0 -11
- package/lib/node/bug-report.spec.js.map +0 -1
- package/lib/node/dino-logo.d.ts.map +0 -1
- package/lib/node/dino-logo.js.map +0 -1
- package/lib/node/exec-extension.d.ts.map +0 -1
- package/lib/node/exec-extension.js.map +0 -1
- package/lib/node/exec-mcp-transport.d.ts.map +0 -1
- package/lib/node/exec-mcp-transport.js.map +0 -1
- package/lib/node/exec-operations.d.ts.map +0 -1
- package/lib/node/exec-operations.js.map +0 -1
- package/lib/node/exec-operations.spec.d.ts +0 -2
- package/lib/node/exec-operations.spec.d.ts.map +0 -1
- package/lib/node/exec-operations.spec.js +0 -77
- package/lib/node/exec-operations.spec.js.map +0 -1
- package/lib/node/extensions.d.ts.map +0 -1
- package/lib/node/extensions.js.map +0 -1
- package/lib/node/extensions.spec.d.ts +0 -2
- package/lib/node/extensions.spec.d.ts.map +0 -1
- package/lib/node/extensions.spec.js +0 -94
- package/lib/node/extensions.spec.js.map +0 -1
- package/lib/node/glob-util.d.ts.map +0 -1
- package/lib/node/glob-util.js.map +0 -1
- package/lib/node/glob-util.spec.d.ts +0 -2
- package/lib/node/glob-util.spec.d.ts.map +0 -1
- package/lib/node/glob-util.spec.js +0 -27
- package/lib/node/glob-util.spec.js.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js.map +0 -1
- package/lib/node/pi-types.d.ts.map +0 -1
- package/lib/node/pi-types.js.map +0 -1
- package/lib/node/remote-context-files.d.ts.map +0 -1
- package/lib/node/remote-context-files.js.map +0 -1
- package/lib/node/remote-context-files.spec.d.ts +0 -2
- package/lib/node/remote-context-files.spec.d.ts.map +0 -1
- package/lib/node/remote-context-files.spec.js +0 -37
- package/lib/node/remote-context-files.spec.js.map +0 -1
- package/lib/node/serve-state.d.ts.map +0 -1
- package/lib/node/serve-state.js.map +0 -1
- package/lib/node/serve-state.spec.d.ts +0 -2
- package/lib/node/serve-state.spec.d.ts.map +0 -1
- package/lib/node/serve-state.spec.js +0 -35
- package/lib/node/serve-state.spec.js.map +0 -1
- package/lib/node/session-lock.d.ts.map +0 -1
- package/lib/node/session-lock.js.map +0 -1
- package/lib/node/session-lock.spec.d.ts +0 -2
- package/lib/node/session-lock.spec.d.ts.map +0 -1
- package/lib/node/session-lock.spec.js +0 -53
- package/lib/node/session-lock.spec.js.map +0 -1
- package/lib/node/ta-brand.d.ts.map +0 -1
- package/lib/node/ta-brand.js.map +0 -1
- package/lib/node/ta-brand.spec.d.ts +0 -2
- package/lib/node/ta-brand.spec.d.ts.map +0 -1
- package/lib/node/ta-brand.spec.js +0 -43
- package/lib/node/ta-brand.spec.js.map +0 -1
- package/lib/node/ta-cli.d.ts.map +0 -1
- package/lib/node/ta-cli.js.map +0 -1
- package/lib/node/ta-header.d.ts.map +0 -1
- package/lib/node/ta-header.js.map +0 -1
- package/lib/node/ta-header.spec.d.ts +0 -2
- package/lib/node/ta-header.spec.d.ts.map +0 -1
- package/lib/node/ta-header.spec.js +0 -67
- package/lib/node/ta-header.spec.js.map +0 -1
- package/lib/node/ta-packages.d.ts.map +0 -1
- package/lib/node/ta-packages.js.map +0 -1
- package/lib/node/ta-packages.spec.d.ts +0 -2
- package/lib/node/ta-packages.spec.d.ts.map +0 -1
- package/lib/node/ta-packages.spec.js +0 -89
- package/lib/node/ta-packages.spec.js.map +0 -1
- package/src/node/brand-extension.spec.ts +0 -63
- package/src/node/brand-extension.ts +0 -40
- package/src/node/bug-report.spec.ts +0 -9
- package/src/node/bug-report.ts +0 -55
- package/src/node/dino-logo.ts +0 -70
- package/src/node/exec-extension.ts +0 -40
- package/src/node/exec-mcp-transport.ts +0 -89
- package/src/node/exec-operations.spec.ts +0 -84
- package/src/node/exec-operations.ts +0 -123
- package/src/node/extensions.spec.ts +0 -110
- package/src/node/extensions.ts +0 -69
- package/src/node/glob-util.spec.ts +0 -29
- package/src/node/glob-util.ts +0 -47
- package/src/node/index.ts +0 -16
- package/src/node/pi-types.ts +0 -16
- package/src/node/remote-context-files.spec.ts +0 -37
- package/src/node/remote-context-files.ts +0 -51
- package/src/node/serve-state.spec.ts +0 -36
- package/src/node/serve-state.ts +0 -51
- package/src/node/session-lock.spec.ts +0 -56
- package/src/node/session-lock.ts +0 -105
- package/src/node/ta-brand.spec.ts +0 -46
- package/src/node/ta-brand.ts +0 -51
- package/src/node/ta-cli.ts +0 -207
- package/src/node/ta-header.spec.ts +0 -74
- package/src/node/ta-header.ts +0 -192
- package/src/node/ta-packages.spec.ts +0 -95
- package/src/node/ta-packages.ts +0 -208
package/README.en.md
CHANGED
|
@@ -11,5 +11,5 @@ Ta's runtime component on pi: the `ta` command and `ta serve` share this code. C
|
|
|
11
11
|
| `ExecExtension`(`ta:exec`) | When the execution environment is not local, replaces read / bash / edit / write / ls / find tools and takes over the `!` command. pi's grep always runs ripgrep locally, so it's disabled (models call rg through bash) |
|
|
12
12
|
| `ExecOperations` | Adapts `ExecEnvironment` to pi tool `*Operations` |
|
|
13
13
|
| `ExecMcpTransport` | Starts a stdio MCP server in the execution environment, passes it to pi's `createMcpExtension({ createTransport })` |
|
|
14
|
-
| `TaPackages` | Ta's built-in pi packages (`@celljs/ta-workspace`, `@celljs/ta-channels`, `@celljs/ta-extensions`, `@celljs/ta-computer-use`, `@celljs/ta-changes`, `@celljs/ta-cron`, `@celljs/ta-agents`): on release they are in `dist/pi/packages/<name>`, in the repo they're resolved from the workspace. Enabled by default; disabled ones are recorded in `ta.json` in the agent directory. The `ta` command loads pi extensions, skills and prompt templates of enabled packages with `--extension` (except package management commands and `--no-extensions`); `ta serve` uses pi ResourceLoader's `additionalExtensionPaths` + `extensionsOverride` / `skillsOverride` / `promptsOverride`, and on `reload` selects by the current switches |
|
|
14
|
+
| `TaPackages` | Ta's built-in pi packages (`@celljs/ta-workspace`, `@celljs/ta-channels`, `@celljs/ta-extensions`, `@celljs/ta-launcher`, `@celljs/ta-computer-use`, `@celljs/ta-changes`, `@celljs/ta-cron`, `@celljs/ta-bots`, `@celljs/ta-agents`): on release they are in `dist/pi/packages/<name>`, in the repo they're resolved from the workspace. Enabled by default; disabled ones are recorded in `ta.json` in the agent directory. The `ta` command loads pi extensions, skills and prompt templates of enabled packages with `--extension` (except package management commands and `--no-extensions`); `ta serve` uses pi ResourceLoader's `additionalExtensionPaths` + `extensionsOverride` / `skillsOverride` / `promptsOverride`, and on `reload` selects by the current switches |
|
|
15
15
|
| `TaExtension` / `TaExtensionUtil` | The shape of Ta's built-in extension: a plain object; `bundle()` combines built-in extensions into one, shown in pi's loaded extension list as `ta` |
|
package/README.md
CHANGED
|
@@ -11,5 +11,5 @@ Ta 在 pi 之上的运行时部件,`ta` 命令和 ta serve 共用。这里的
|
|
|
11
11
|
| `ExecExtension`(`ta:exec`) | 执行环境不在本机时,用同名工具替换 read / bash / edit / write / ls / find 并接管 `!` 命令;pi 的 grep 总在本机跑 ripgrep,所以停用它(模型会通过 bash 用 rg) |
|
|
12
12
|
| `ExecOperations` | 把 `ExecEnvironment` 适配成 pi 工具的 `*Operations` |
|
|
13
13
|
| `ExecMcpTransport` | 在执行环境里启动 stdio MCP 服务,交给 pi 的 `createMcpExtension({ createTransport })` |
|
|
14
|
-
| `TaPackages` | Ta 自带的 pi 包(`@celljs/ta-workspace`、`@celljs/ta-channels`、`@celljs/ta-extensions`、`@celljs/ta-computer-use`、`@celljs/ta-changes`、`@celljs/ta-cron`、`@celljs/ta-agents`):发布时在 `dist/pi/packages/<名字>`,仓库里从工作区解析;默认开启,关掉的记在 agent 目录的 `ta.json`。`ta` 命令用 `--extension` 加载开启着的包的 pi 扩展、技能和提示模板(包管理命令和 `--no-extensions` 除外),ta serve 用 pi ResourceLoader 的 `additionalExtensionPaths` + `extensionsOverride` / `skillsOverride` / `promptsOverride`,`reload` 时按当时的开关取舍 |
|
|
14
|
+
| `TaPackages` | Ta 自带的 pi 包(`@celljs/ta-workspace`、`@celljs/ta-channels`、`@celljs/ta-extensions`、`@celljs/ta-launcher`、`@celljs/ta-computer-use`、`@celljs/ta-changes`、`@celljs/ta-cron`、`@celljs/ta-bots`、`@celljs/ta-agents`):发布时在 `dist/pi/packages/<名字>`,仓库里从工作区解析;默认开启,关掉的记在 agent 目录的 `ta.json`。`ta` 命令用 `--extension` 加载开启着的包的 pi 扩展、技能和提示模板(包管理命令和 `--no-extensions` 除外),ta serve 用 pi ResourceLoader 的 `additionalExtensionPaths` + `extensionsOverride` / `skillsOverride` / `promptsOverride`,`reload` 时按当时的开关取舍 |
|
|
15
15
|
| `TaExtension` / `TaExtensionUtil` | Ta 的内置扩展形状:普通对象;`bundle()` 把内置扩展合成一个,pi 的已加载扩展列表里显示为 `ta` |
|
package/esm/node/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './exec-mcp-transport.js';
|
|
|
6
6
|
export * from './exec-operations.js';
|
|
7
7
|
export * from './extensions.js';
|
|
8
8
|
export * from './glob-util.js';
|
|
9
|
+
export * from './package-archive.js';
|
|
9
10
|
export * from './pi-types.js';
|
|
10
11
|
export * from './remote-context-files.js';
|
|
11
12
|
export * from './serve-state.js';
|
package/esm/node/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './exec-mcp-transport.js';
|
|
|
6
6
|
export * from './exec-operations.js';
|
|
7
7
|
export * from './extensions.js';
|
|
8
8
|
export * from './glob-util.js';
|
|
9
|
+
export * from './package-archive.js';
|
|
9
10
|
export * from './pi-types.js';
|
|
10
11
|
export * from './remote-context-files.js';
|
|
11
12
|
export * from './serve-state.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** A file of a package, by its path inside the package, with `/` between the parts. */
|
|
2
|
+
export interface ArchiveFile {
|
|
3
|
+
path: string;
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
executable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** An archive read back: the directory at its top and the files under it, by their paths inside it. */
|
|
8
|
+
export interface UnpackedArchive {
|
|
9
|
+
top: string;
|
|
10
|
+
files: ArchiveFile[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A package in one file to hand on: a gzipped tar of its directory, as `tar -czf <name>.tgz <name>` makes
|
|
14
|
+
* it, so that `tar` reads it too. Only directories and plain files; links and the rest are left out.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace PackageArchive {
|
|
17
|
+
/** Unpacked, at most: a package is code and a few assets, not data. */
|
|
18
|
+
const MAX_BYTES: number;
|
|
19
|
+
const MAX_FILES = 5000;
|
|
20
|
+
/** The files of the package in `root`, without node_modules and .git; links are left out. */
|
|
21
|
+
function collect(root: string): ArchiveFile[];
|
|
22
|
+
/**
|
|
23
|
+
* Puts the files of an archive in `target`, in place of what was there: written beside it under a name
|
|
24
|
+
* pi skips (a dot), then renamed, so that a session never loads half of it.
|
|
25
|
+
*/
|
|
26
|
+
function extract(files: readonly ArchiveFile[], target: string): void;
|
|
27
|
+
/** The `name` of the package.json of an archive's files, if it has one. */
|
|
28
|
+
function nameOf(files: readonly ArchiveFile[]): string | undefined;
|
|
29
|
+
/** The directory of a package: its name without scope, in the letters a directory takes everywhere. */
|
|
30
|
+
function directoryName(name: string): string;
|
|
31
|
+
function pack(top: string, files: ArchiveFile[], mtime?: number): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* The files of an archive of {@link pack}, or of any tar of one directory (`npm pack` makes one of
|
|
34
|
+
* `package/`). Throws for what is not one: paths out of the directory, more than one at the top, no
|
|
35
|
+
* package.json there, more than the limits.
|
|
36
|
+
*/
|
|
37
|
+
function unpack(archive: Uint8Array): UnpackedArchive;
|
|
38
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { chmodSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { gunzipSync, gzipSync } from 'node:zlib';
|
|
5
|
+
const BLOCK = 512;
|
|
6
|
+
/** What a package carries that the one who gets it installs or has already. */
|
|
7
|
+
const LEFT_OUT = new Set(['node_modules', '.git', '.DS_Store']);
|
|
8
|
+
/**
|
|
9
|
+
* A package in one file to hand on: a gzipped tar of its directory, as `tar -czf <name>.tgz <name>` makes
|
|
10
|
+
* it, so that `tar` reads it too. Only directories and plain files; links and the rest are left out.
|
|
11
|
+
*/
|
|
12
|
+
export var PackageArchive;
|
|
13
|
+
(function (PackageArchive) {
|
|
14
|
+
/** Unpacked, at most: a package is code and a few assets, not data. */
|
|
15
|
+
PackageArchive.MAX_BYTES = 20 * 1024 * 1024;
|
|
16
|
+
PackageArchive.MAX_FILES = 5000;
|
|
17
|
+
/** The files of the package in `root`, without node_modules and .git; links are left out. */
|
|
18
|
+
function collect(root) {
|
|
19
|
+
const files = [];
|
|
20
|
+
let bytes = 0;
|
|
21
|
+
const walk = (directory, prefix) => {
|
|
22
|
+
for (const name of readdirSync(directory).sort()) {
|
|
23
|
+
if (LEFT_OUT.has(name)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const file = join(directory, name);
|
|
27
|
+
const stat = lstatSync(file);
|
|
28
|
+
const path = prefix ? `${prefix}/${name}` : name;
|
|
29
|
+
if (stat.isDirectory()) {
|
|
30
|
+
walk(file, path);
|
|
31
|
+
}
|
|
32
|
+
else if (stat.isFile()) {
|
|
33
|
+
bytes += stat.size;
|
|
34
|
+
if (files.length >= PackageArchive.MAX_FILES || bytes > PackageArchive.MAX_BYTES) {
|
|
35
|
+
throw new Error(`The package in ${root} is larger than ${PackageArchive.MAX_FILES} files or ${PackageArchive.MAX_BYTES / 1024 / 1024} MB.`);
|
|
36
|
+
}
|
|
37
|
+
files.push({ path, data: readFileSync(file), executable: (stat.mode & 0o111) !== 0 });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
walk(root, '');
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
PackageArchive.collect = collect;
|
|
45
|
+
/**
|
|
46
|
+
* Puts the files of an archive in `target`, in place of what was there: written beside it under a name
|
|
47
|
+
* pi skips (a dot), then renamed, so that a session never loads half of it.
|
|
48
|
+
*/
|
|
49
|
+
function extract(files, target) {
|
|
50
|
+
const staging = join(dirname(target), `.${basename(target)}.${randomBytes(4).toString('hex')}`);
|
|
51
|
+
try {
|
|
52
|
+
for (const file of files) {
|
|
53
|
+
const path = join(staging, ...file.path.split('/'));
|
|
54
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
55
|
+
writeFileSync(path, file.data);
|
|
56
|
+
if (file.executable) {
|
|
57
|
+
chmodSync(path, 0o755);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
rmSync(target, { recursive: true, force: true });
|
|
61
|
+
renameSync(staging, target);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
rmSync(staging, { recursive: true, force: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
PackageArchive.extract = extract;
|
|
68
|
+
/** The `name` of the package.json of an archive's files, if it has one. */
|
|
69
|
+
function nameOf(files) {
|
|
70
|
+
var _a;
|
|
71
|
+
var _b;
|
|
72
|
+
const manifest = files.find(file => file.path === 'package.json');
|
|
73
|
+
try {
|
|
74
|
+
const name = (_a = JSON.parse(Buffer.from((_b = manifest === null || manifest === void 0 ? void 0 : manifest.data) !== null && _b !== void 0 ? _b : []).toString('utf8'))) === null || _a === void 0 ? void 0 : _a.name;
|
|
75
|
+
return typeof name === 'string' && name.trim() ? name.trim() : undefined;
|
|
76
|
+
}
|
|
77
|
+
catch (_c) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
PackageArchive.nameOf = nameOf;
|
|
82
|
+
/** The directory of a package: its name without scope, in the letters a directory takes everywhere. */
|
|
83
|
+
function directoryName(name) {
|
|
84
|
+
const plain = name
|
|
85
|
+
.slice(name.lastIndexOf('/') + 1)
|
|
86
|
+
.toLowerCase()
|
|
87
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
88
|
+
.replace(/^[-.]+|-+$/g, '');
|
|
89
|
+
return plain || 'extension';
|
|
90
|
+
}
|
|
91
|
+
PackageArchive.directoryName = directoryName;
|
|
92
|
+
function pack(top, files, mtime = Date.now()) {
|
|
93
|
+
const blocks = [header(`${top}/`, 0, 0o755, '5', mtime)];
|
|
94
|
+
const directories = new Set();
|
|
95
|
+
for (const file of files) {
|
|
96
|
+
const parts = file.path.split('/');
|
|
97
|
+
for (let i = 1; i < parts.length; i++) {
|
|
98
|
+
const directory = parts.slice(0, i).join('/');
|
|
99
|
+
if (!directories.has(directory)) {
|
|
100
|
+
directories.add(directory);
|
|
101
|
+
blocks.push(header(`${top}/${directory}/`, 0, 0o755, '5', mtime));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
blocks.push(header(`${top}/${file.path}`, file.data.length, file.executable ? 0o755 : 0o644, '0', mtime));
|
|
105
|
+
blocks.push(file.data, new Uint8Array(padding(file.data.length)));
|
|
106
|
+
}
|
|
107
|
+
blocks.push(new Uint8Array(BLOCK * 2));
|
|
108
|
+
return gzipSync(Buffer.concat(blocks));
|
|
109
|
+
}
|
|
110
|
+
PackageArchive.pack = pack;
|
|
111
|
+
/**
|
|
112
|
+
* The files of an archive of {@link pack}, or of any tar of one directory (`npm pack` makes one of
|
|
113
|
+
* `package/`). Throws for what is not one: paths out of the directory, more than one at the top, no
|
|
114
|
+
* package.json there, more than the limits.
|
|
115
|
+
*/
|
|
116
|
+
function unpack(archive) {
|
|
117
|
+
var _a;
|
|
118
|
+
let tar;
|
|
119
|
+
try {
|
|
120
|
+
tar = gunzipSync(archive, { maxOutputLength: PackageArchive.MAX_BYTES + PackageArchive.MAX_FILES * BLOCK * 2 });
|
|
121
|
+
}
|
|
122
|
+
catch (_b) {
|
|
123
|
+
throw new Error('The file is not a .tgz of a package, or is larger than the limit.');
|
|
124
|
+
}
|
|
125
|
+
const files = [];
|
|
126
|
+
let top;
|
|
127
|
+
let longPath;
|
|
128
|
+
let bytes = 0;
|
|
129
|
+
for (let offset = 0; offset + BLOCK <= tar.length;) {
|
|
130
|
+
const block = tar.subarray(offset, offset + BLOCK);
|
|
131
|
+
if (block.every(byte => byte === 0)) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (!checksumOk(block)) {
|
|
135
|
+
throw new Error('The file is not a .tgz of a package: a header of it is broken.');
|
|
136
|
+
}
|
|
137
|
+
const size = octal(block.subarray(124, 136));
|
|
138
|
+
const type = String.fromCharCode(block[156] || 48);
|
|
139
|
+
const body = tar.subarray(offset + BLOCK, offset + BLOCK + size);
|
|
140
|
+
offset += BLOCK + size + padding(size);
|
|
141
|
+
if (type === 'x') {
|
|
142
|
+
longPath = (_a = paxPath(body)) !== null && _a !== void 0 ? _a : longPath;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (type === 'L') {
|
|
146
|
+
longPath = text(body);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const name = longPath !== null && longPath !== void 0 ? longPath : joinName(text(block.subarray(345, 500)), text(block.subarray(0, 100)));
|
|
150
|
+
longPath = undefined;
|
|
151
|
+
if (type !== '0' && type !== '7' && type !== '5') {
|
|
152
|
+
// Links, devices, global headers: a package has none that matter.
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const parts = safeParts(name);
|
|
156
|
+
if (parts.some(part => part.startsWith('._') || part === '__MACOSX')) {
|
|
157
|
+
// What the tar of macOS adds for the attributes of each file.
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (top === undefined) {
|
|
161
|
+
top = parts[0];
|
|
162
|
+
}
|
|
163
|
+
else if (parts[0] !== top) {
|
|
164
|
+
throw new Error(`The file holds more than one directory: ${top} and ${parts[0]}.`);
|
|
165
|
+
}
|
|
166
|
+
if (type === '5' || parts.length === 1) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
bytes += size;
|
|
170
|
+
if (files.length >= PackageArchive.MAX_FILES || bytes > PackageArchive.MAX_BYTES) {
|
|
171
|
+
throw new Error(`The package is larger than ${PackageArchive.MAX_FILES} files or ${PackageArchive.MAX_BYTES / 1024 / 1024} MB.`);
|
|
172
|
+
}
|
|
173
|
+
files.push({ path: parts.slice(1).join('/'), data: new Uint8Array(body), executable: (octal(block.subarray(100, 108)) & 0o111) !== 0 });
|
|
174
|
+
}
|
|
175
|
+
if (top === undefined || !files.some(file => file.path === 'package.json')) {
|
|
176
|
+
throw new Error('The file is not a package: it has no package.json in its directory.');
|
|
177
|
+
}
|
|
178
|
+
return { top, files };
|
|
179
|
+
}
|
|
180
|
+
PackageArchive.unpack = unpack;
|
|
181
|
+
function header(path, size, mode, type, mtime) {
|
|
182
|
+
const block = Buffer.alloc(BLOCK);
|
|
183
|
+
const [prefix, name] = split(path);
|
|
184
|
+
block.write(name, 0, 100, 'utf8');
|
|
185
|
+
field(block, 100, 8, mode);
|
|
186
|
+
field(block, 108, 8, 0);
|
|
187
|
+
field(block, 116, 8, 0);
|
|
188
|
+
field(block, 124, 12, size);
|
|
189
|
+
field(block, 136, 12, Math.floor(mtime / 1000));
|
|
190
|
+
block.write(type, 156, 1, 'latin1');
|
|
191
|
+
block.write('ustar\u000000', 257, 8, 'latin1');
|
|
192
|
+
block.write(prefix, 345, 155, 'utf8');
|
|
193
|
+
block.fill(32, 148, 156);
|
|
194
|
+
const sum = block.reduce((total, byte) => total + byte, 0);
|
|
195
|
+
block.write(`${sum.toString(8).padStart(6, '0')}\u0000 `, 148, 8, 'latin1');
|
|
196
|
+
return block;
|
|
197
|
+
}
|
|
198
|
+
/** ustar's two fields of a path: up to 155 bytes of directories, and up to 100 bytes of the rest. */
|
|
199
|
+
function split(path) {
|
|
200
|
+
if (Buffer.byteLength(path) <= 100) {
|
|
201
|
+
return ['', path];
|
|
202
|
+
}
|
|
203
|
+
for (let at = path.indexOf('/'); at > 0; at = path.indexOf('/', at + 1)) {
|
|
204
|
+
const prefix = path.slice(0, at);
|
|
205
|
+
const name = path.slice(at + 1);
|
|
206
|
+
if (Buffer.byteLength(prefix) <= 155 && Buffer.byteLength(name) <= 100) {
|
|
207
|
+
return [prefix, name];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`The path ${path} is too long for the archive.`);
|
|
211
|
+
}
|
|
212
|
+
function field(block, offset, length, value) {
|
|
213
|
+
block.write(`${value.toString(8).padStart(length - 1, '0')}\u0000`, offset, length, 'latin1');
|
|
214
|
+
}
|
|
215
|
+
function octal(bytes) {
|
|
216
|
+
const value = Number.parseInt(text(bytes).trim() || '0', 8);
|
|
217
|
+
return Number.isFinite(value) ? value : 0;
|
|
218
|
+
}
|
|
219
|
+
function text(bytes) {
|
|
220
|
+
const end = bytes.indexOf(0);
|
|
221
|
+
return Buffer.from(end < 0 ? bytes : bytes.subarray(0, end)).toString('utf8');
|
|
222
|
+
}
|
|
223
|
+
function checksumOk(block) {
|
|
224
|
+
let sum = 0;
|
|
225
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
226
|
+
sum += i >= 148 && i < 156 ? 32 : block[i];
|
|
227
|
+
}
|
|
228
|
+
return sum === octal(block.subarray(148, 156));
|
|
229
|
+
}
|
|
230
|
+
function joinName(prefix, name) {
|
|
231
|
+
return prefix ? `${prefix}/${name}` : name;
|
|
232
|
+
}
|
|
233
|
+
/** The `path` record of a pax header: `<length> path=<path>\n`. */
|
|
234
|
+
function paxPath(body) {
|
|
235
|
+
for (const record of Buffer.from(body).toString('utf8').split('\n')) {
|
|
236
|
+
const match = /^\d+ path=(.*)$/.exec(record);
|
|
237
|
+
if (match) {
|
|
238
|
+
return match[1];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
/** The parts of a path that stays in the directory of the archive: nothing absolute, no `..`. */
|
|
244
|
+
function safeParts(path) {
|
|
245
|
+
if (path.startsWith('/') || path.includes('\\') || path.includes('\u0000') || /^[a-zA-Z]:/.test(path)) {
|
|
246
|
+
throw new Error(`The file has a path out of its directory: ${path}`);
|
|
247
|
+
}
|
|
248
|
+
const parts = path.split('/').filter(part => part !== '' && part !== '.');
|
|
249
|
+
if (parts.length === 0 || parts.some(part => part === '..')) {
|
|
250
|
+
throw new Error(`The file has a path out of its directory: ${path}`);
|
|
251
|
+
}
|
|
252
|
+
return parts;
|
|
253
|
+
}
|
|
254
|
+
function padding(size) {
|
|
255
|
+
return (BLOCK - (size % BLOCK)) % BLOCK;
|
|
256
|
+
}
|
|
257
|
+
})(PackageArchive || (PackageArchive = {}));
|
|
258
|
+
//# sourceMappingURL=package-archive.js.map
|
|
@@ -15,4 +15,12 @@ export declare namespace TaServeStateUtil {
|
|
|
15
15
|
function write(state: TaServeState, path?: string): void;
|
|
16
16
|
/** Whether a server could listen on `port` of `host` now. */
|
|
17
17
|
function isFree(port: number, host: string): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* The ta serve that serve.json (TA_SERVE_FILE of @celljs/ta-protocol) names for the agent directory, when
|
|
20
|
+
* its process is alive and it answers: what a second one would fight over sessions and the relay with.
|
|
21
|
+
*/
|
|
22
|
+
function running(agentDir?: string, timeoutMs?: number): Promise<{
|
|
23
|
+
url: string;
|
|
24
|
+
pid: number;
|
|
25
|
+
} | undefined>;
|
|
18
26
|
}
|
package/esm/node/serve-state.js
CHANGED
|
@@ -40,5 +40,41 @@ export var TaServeStateUtil;
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
TaServeStateUtil.isFree = isFree;
|
|
43
|
+
/**
|
|
44
|
+
* The ta serve that serve.json (TA_SERVE_FILE of @celljs/ta-protocol) names for the agent directory, when
|
|
45
|
+
* its process is alive and it answers: what a second one would fight over sessions and the relay with.
|
|
46
|
+
*/
|
|
47
|
+
async function running(agentDir = TaBrand.agentDir(), timeoutMs = 2000) {
|
|
48
|
+
var _a;
|
|
49
|
+
let info;
|
|
50
|
+
try {
|
|
51
|
+
info = JSON.parse(readFileSync(join(agentDir, 'serve.json'), 'utf8'));
|
|
52
|
+
}
|
|
53
|
+
catch (_b) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const { url, pid } = info;
|
|
57
|
+
if (typeof url !== 'string' || typeof pid !== 'number' || pid === process.pid || !isAlive(pid)) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const response = await fetch(`${url.replace(/^ws/, 'http').replace(/\/api\/ws$/, '')}/`, { signal: AbortSignal.timeout(timeoutMs) });
|
|
62
|
+
await ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
63
|
+
return { url, pid };
|
|
64
|
+
}
|
|
65
|
+
catch (_c) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
TaServeStateUtil.running = running;
|
|
70
|
+
function isAlive(pid) {
|
|
71
|
+
try {
|
|
72
|
+
process.kill(pid, 0);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return error.code === 'EPERM';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
43
79
|
})(TaServeStateUtil || (TaServeStateUtil = {}));
|
|
44
80
|
//# sourceMappingURL=serve-state.js.map
|
package/esm/node/ta-cli.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface TaCliOptions {
|
|
|
3
3
|
brandDir: string;
|
|
4
4
|
/** The built server of `ta serve`. */
|
|
5
5
|
serveEntry: string;
|
|
6
|
+
/** The built `ta gateway` (GatewayCli of @celljs/ta-gateway), beside it: dist/gateway.mjs. */
|
|
7
|
+
gatewayEntry?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare namespace TaCli {
|
|
8
10
|
/**
|
package/esm/node/ta-cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
2
3
|
import { parseArgs } from 'node:util';
|
|
3
4
|
import { PiBundleUtil } from '@celljs/ai-coding-agent/lib/node/pi/pi-bundle-util';
|
|
4
5
|
import { BrandExtension } from './brand-extension.js';
|
|
@@ -19,7 +20,12 @@ Serves ta sessions over WebSocket to any number of clients, and the web client.
|
|
|
19
20
|
|
|
20
21
|
The URL and the access token are written to serve.json in the agent directory. The token stays the
|
|
21
22
|
same across restarts (serve-state.json there; remove it for a new token and port).
|
|
22
|
-
Set TA_SERVE_TOKEN to choose the token.
|
|
23
|
+
Set TA_SERVE_TOKEN to choose the token. One ta serve runs for an agent directory: a second one exits.
|
|
24
|
+
|
|
25
|
+
On an address of the network (--host 0.0.0.0, in a container) it prints the link that signs in, at
|
|
26
|
+
TA_PUBLIC_URL if set. People can also sign in with GitHub, Google, WeChat or an OpenID Connect provider
|
|
27
|
+
(TA_GITHUB_*, TA_GOOGLE_*, TA_WECHAT_*, TA_OIDC_*) when their account is in TA_ALLOWED_USERS or added in
|
|
28
|
+
the web client; see the README of @celljs/ta-host.
|
|
23
29
|
`;
|
|
24
30
|
const EXEC_SERVER_HELP = `Usage: ta exec-server [--host <host>] [--port <port>] [--cwd <dir>]
|
|
25
31
|
|
|
@@ -45,7 +51,7 @@ const PAIR_HELP = `Usage: ta pair [<relay url>] [--name <device>]
|
|
|
45
51
|
ta pair --remove <device id>
|
|
46
52
|
|
|
47
53
|
Pairs a device, such as a phone, with the ta serve of this user: prints a link to paste in the Ta app on
|
|
48
|
-
it. The relay is https://relay.cellbang.com unless named. With a device paired, ta serve connects to the relay; what goes through it is encrypted end to end,
|
|
54
|
+
it, and in a terminal a QR code of it to scan. The relay is https://relay.cellbang.com unless named. With a device paired, ta serve connects to the relay; what goes through it is encrypted end to end,
|
|
49
55
|
with a key only the device and ta serve have. The devices are in relay.json in the agent directory.
|
|
50
56
|
`;
|
|
51
57
|
export var TaCli;
|
|
@@ -68,6 +74,15 @@ export var TaCli;
|
|
|
68
74
|
await pair(argv.slice(1));
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
77
|
+
if (argv[0] === 'gateway' && options.gatewayEntry) {
|
|
78
|
+
// Without Cell, as the exec server; its web client is that of ta serve.
|
|
79
|
+
const { GatewayCli } = await import(/* @vite-ignore */ options.gatewayEntry);
|
|
80
|
+
await GatewayCli.run(argv.slice(1), {
|
|
81
|
+
publicDir: join(dirname(options.serveEntry), '..', 'public'),
|
|
82
|
+
taCommand: [process.execPath, process.argv[1]],
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
71
86
|
if (argv[0] === 'exec-server') {
|
|
72
87
|
await execServer(argv.slice(1));
|
|
73
88
|
return;
|
|
@@ -93,6 +108,19 @@ export var TaCli;
|
|
|
93
108
|
process.stdout.write(SERVE_HELP);
|
|
94
109
|
return;
|
|
95
110
|
}
|
|
111
|
+
const other = await TaServeStateUtil.running();
|
|
112
|
+
if (other) {
|
|
113
|
+
// Two would hold each other's sessions locked and take the relay from each other.
|
|
114
|
+
console.error(`ta serve: one already runs for ${TaBrand.agentDir()}, at ${other.url} (pid ${other.pid}). Stop it first, or give this one another TA_CODING_AGENT_DIR.`);
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (process.env.TA_SERVE_STDIN_LIFELINE) {
|
|
119
|
+
delete process.env.TA_SERVE_STDIN_LIFELINE;
|
|
120
|
+
// Started by an app that stops it when it quits (ta-desktop): it goes with the app, one that crashed too.
|
|
121
|
+
process.stdin.once('end', () => process.kill(process.pid, 'SIGTERM'));
|
|
122
|
+
process.stdin.resume();
|
|
123
|
+
}
|
|
96
124
|
// This process is already Node.js; in the commands of the agent, an Electron app would start as Node.js too.
|
|
97
125
|
delete process.env.ELECTRON_RUN_AS_NODE;
|
|
98
126
|
// Read by the server like any other key of its configuration.
|
|
@@ -166,8 +194,21 @@ export var TaCli;
|
|
|
166
194
|
return;
|
|
167
195
|
}
|
|
168
196
|
const pairing = store.pair(relayUrl, (_a = values.name) !== null && _a !== void 0 ? _a : 'device');
|
|
169
|
-
|
|
170
|
-
|
|
197
|
+
const link = RelayPairingUtil.link(pairing);
|
|
198
|
+
if (process.stdout.isTTY) {
|
|
199
|
+
// Dark on light whatever the colors of the terminal, which a camera reads.
|
|
200
|
+
const { QrCode } = await import('@celljs/ta-relay/lib/common/qr-code');
|
|
201
|
+
console.log('Scan this code with the Ta app on the device, or paste the link below in it. Anyone with them can reach your Ta: keep them to yourself.\n');
|
|
202
|
+
console.log(QrCode.encode(link)
|
|
203
|
+
.lines()
|
|
204
|
+
.map(line => `\x1b[30;107m${line}\x1b[0m`)
|
|
205
|
+
.join('\n'));
|
|
206
|
+
console.log();
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
console.log('Paste this link in the Ta app on the device. Anyone with it can reach your Ta: keep it to yourself.\n');
|
|
210
|
+
}
|
|
211
|
+
console.log(link);
|
|
171
212
|
console.log(`\nDevice id: ${pairing.device} (ta pair --remove ${pairing.device} to unpair it)`);
|
|
172
213
|
}
|
|
173
214
|
/** Without Cell: the exec server is a plain HTTP server, as small as it can be. */
|
|
@@ -40,6 +40,7 @@ export interface TaBuiltinPackage {
|
|
|
40
40
|
* directory (PI_PACKAGE_DIR); in the repository they are the workspace packages of {@link BUILTIN}.
|
|
41
41
|
*/
|
|
42
42
|
export declare namespace TaPackages {
|
|
43
|
+
/** In the order the settings list them. */
|
|
43
44
|
const BUILTIN: readonly string[];
|
|
44
45
|
/** In the agent directory. */
|
|
45
46
|
const SETTINGS_FILE = "ta.json";
|
package/esm/node/ta-packages.js
CHANGED
|
@@ -14,20 +14,23 @@ const PACKAGE_COMMANDS = new Set(['install', 'remove', 'uninstall', 'update', 'l
|
|
|
14
14
|
*/
|
|
15
15
|
export var TaPackages;
|
|
16
16
|
(function (TaPackages) {
|
|
17
|
+
/** In the order the settings list them. */
|
|
17
18
|
TaPackages.BUILTIN = [
|
|
18
19
|
'@celljs/ta-workspace',
|
|
19
20
|
'@celljs/ta-channels',
|
|
20
21
|
'@celljs/ta-extensions',
|
|
22
|
+
'@celljs/ta-launcher',
|
|
21
23
|
'@celljs/ta-computer-use',
|
|
22
24
|
'@celljs/ta-changes',
|
|
23
25
|
'@celljs/ta-cron',
|
|
26
|
+
'@celljs/ta-bots',
|
|
24
27
|
'@celljs/ta-agents',
|
|
25
28
|
];
|
|
26
29
|
/** In the agent directory. */
|
|
27
30
|
TaPackages.SETTINGS_FILE = 'ta.json';
|
|
28
31
|
function builtins(packageDir = process.env.PI_PACKAGE_DIR) {
|
|
29
32
|
const dir = packageDir ? join(packageDir, 'packages') : undefined;
|
|
30
|
-
return dir && existsSync(dir) ? described(subdirectories(dir)) : workspace();
|
|
33
|
+
return dir && existsSync(dir) ? ordered(described(subdirectories(dir))) : workspace();
|
|
31
34
|
}
|
|
32
35
|
TaPackages.builtins = builtins;
|
|
33
36
|
/** Not built: those of {@link BUILTIN} that are installed next to this file, in the repository. */
|
|
@@ -148,6 +151,17 @@ export var TaPackages;
|
|
|
148
151
|
.map(entry => join(dir, entry.name))
|
|
149
152
|
.sort();
|
|
150
153
|
}
|
|
154
|
+
/** Those of {@link BUILTIN} in its order, then the others as they were. */
|
|
155
|
+
function ordered(packages) {
|
|
156
|
+
const rank = (pkg) => {
|
|
157
|
+
const index = TaPackages.BUILTIN.indexOf(pkg.name);
|
|
158
|
+
return index < 0 ? TaPackages.BUILTIN.length : index;
|
|
159
|
+
};
|
|
160
|
+
return packages
|
|
161
|
+
.map((pkg, index) => ({ pkg, index }))
|
|
162
|
+
.sort((a, b) => rank(a.pkg) - rank(b.pkg) || a.index - b.index)
|
|
163
|
+
.map(({ pkg }) => pkg);
|
|
164
|
+
}
|
|
151
165
|
function described(roots) {
|
|
152
166
|
return roots.flatMap(root => {
|
|
153
167
|
const pkg = describe(root);
|
package/lib/node/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './exec-mcp-transport';
|
|
|
6
6
|
export * from './exec-operations';
|
|
7
7
|
export * from './extensions';
|
|
8
8
|
export * from './glob-util';
|
|
9
|
+
export * from './package-archive';
|
|
9
10
|
export * from './pi-types';
|
|
10
11
|
export * from './remote-context-files';
|
|
11
12
|
export * from './serve-state';
|
package/lib/node/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./exec-mcp-transport"), exports);
|
|
|
22
22
|
__exportStar(require("./exec-operations"), exports);
|
|
23
23
|
__exportStar(require("./extensions"), exports);
|
|
24
24
|
__exportStar(require("./glob-util"), exports);
|
|
25
|
+
__exportStar(require("./package-archive"), exports);
|
|
25
26
|
__exportStar(require("./pi-types"), exports);
|
|
26
27
|
__exportStar(require("./remote-context-files"), exports);
|
|
27
28
|
__exportStar(require("./serve-state"), exports);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** A file of a package, by its path inside the package, with `/` between the parts. */
|
|
2
|
+
export interface ArchiveFile {
|
|
3
|
+
path: string;
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
executable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** An archive read back: the directory at its top and the files under it, by their paths inside it. */
|
|
8
|
+
export interface UnpackedArchive {
|
|
9
|
+
top: string;
|
|
10
|
+
files: ArchiveFile[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A package in one file to hand on: a gzipped tar of its directory, as `tar -czf <name>.tgz <name>` makes
|
|
14
|
+
* it, so that `tar` reads it too. Only directories and plain files; links and the rest are left out.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace PackageArchive {
|
|
17
|
+
/** Unpacked, at most: a package is code and a few assets, not data. */
|
|
18
|
+
const MAX_BYTES: number;
|
|
19
|
+
const MAX_FILES = 5000;
|
|
20
|
+
/** The files of the package in `root`, without node_modules and .git; links are left out. */
|
|
21
|
+
function collect(root: string): ArchiveFile[];
|
|
22
|
+
/**
|
|
23
|
+
* Puts the files of an archive in `target`, in place of what was there: written beside it under a name
|
|
24
|
+
* pi skips (a dot), then renamed, so that a session never loads half of it.
|
|
25
|
+
*/
|
|
26
|
+
function extract(files: readonly ArchiveFile[], target: string): void;
|
|
27
|
+
/** The `name` of the package.json of an archive's files, if it has one. */
|
|
28
|
+
function nameOf(files: readonly ArchiveFile[]): string | undefined;
|
|
29
|
+
/** The directory of a package: its name without scope, in the letters a directory takes everywhere. */
|
|
30
|
+
function directoryName(name: string): string;
|
|
31
|
+
function pack(top: string, files: ArchiveFile[], mtime?: number): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* The files of an archive of {@link pack}, or of any tar of one directory (`npm pack` makes one of
|
|
34
|
+
* `package/`). Throws for what is not one: paths out of the directory, more than one at the top, no
|
|
35
|
+
* package.json there, more than the limits.
|
|
36
|
+
*/
|
|
37
|
+
function unpack(archive: Uint8Array): UnpackedArchive;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=package-archive.d.ts.map
|