code60-transmission-server 0.1.0-staging.13 → 0.1.0-staging.16
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/INTENT.md +47 -0
- package/README.md +36 -345
- package/dist/src/acp.js +115 -0
- package/dist/src/contract.js +60 -0
- package/dist/src/engine.js +481 -0
- package/dist/src/main.js +70 -25
- package/dist/src/repository.js +94 -0
- package/dist/src/service.js +184 -0
- package/package.json +16 -35
- package/reference/openapi.json +423 -0
- package/README.engine.md +0 -463
- package/dist/src/broker/filesystem.js +0 -385
- package/dist/src/broker/index.js +0 -777
- package/dist/src/broker/native/README.md +0 -207
- package/dist/src/broker/native/build.js +0 -46
- package/dist/src/broker/native/command-helper.c +0 -93
- package/dist/src/broker/native/fs-helper.c +0 -529
- package/dist/src/broker/native/git-helper.c +0 -205
- package/dist/src/broker/policy.js +0 -149
- package/dist/src/broker/startup-lock.js +0 -14
- package/dist/src/broker/types.js +0 -11
- package/dist/src/cli/configure.js +0 -208
- package/dist/src/cli/daemon.js +0 -369
- package/dist/src/cli/helpers.js +0 -112
- package/dist/src/cli/main.js +0 -189
- package/dist/src/cli/runtime-build.js +0 -38
- package/dist/src/config/coding-policy.js +0 -4
- package/dist/src/config/deployment.js +0 -183
- package/dist/src/config/documents.js +0 -29
- package/dist/src/config/profile-validation.js +0 -129
- package/dist/src/config/schema-graph.js +0 -237
- package/dist/src/config/schema-loader.js +0 -185
- package/dist/src/config/validation-pool.js +0 -105
- package/dist/src/config/validation-protocol.js +0 -1
- package/dist/src/config/validation-worker.js +0 -106
- package/dist/src/config/workflow-language.js +0 -9
- package/dist/src/config/workflow-schema.json +0 -545
- package/dist/src/config/workflow-types.js +0 -1
- package/dist/src/config/workflow-validation.js +0 -95
- package/dist/src/engine/budgets.js +0 -50
- package/dist/src/engine/clocks.js +0 -27
- package/dist/src/engine/commands.js +0 -477
- package/dist/src/engine/contracts.js +0 -11
- package/dist/src/engine/drain-state.js +0 -31
- package/dist/src/engine/effective-permissions.js +0 -120
- package/dist/src/engine/instruction-pins.js +0 -205
- package/dist/src/engine/retries.js +0 -50
- package/dist/src/engine/state.js +0 -1
- package/dist/src/engine/timing.js +0 -23
- package/dist/src/engine/tool-observations.js +0 -87
- package/dist/src/engine/workflow-engine.js +0 -1864
- package/dist/src/mcp/catalog.js +0 -71
- package/dist/src/mcp/main.js +0 -26
- package/dist/src/mcp/server.js +0 -177
- package/dist/src/runtime/codex-app-server.js +0 -91
- package/dist/src/runtime/codex-executable.js +0 -50
- package/dist/src/runtime/containment.js +0 -82
- package/dist/src/runtime/engine-driver.js +0 -221
- package/dist/src/runtime/json-line-writer.js +0 -192
- package/dist/src/runtime/pinned-instruction-sources.js +0 -24
- package/dist/src/runtime/protocol-client.js +0 -264
- package/dist/src/runtime/protocol-pool.js +0 -183
- package/dist/src/runtime/protocol-projection.js +0 -393
- package/dist/src/runtime/protocol-types.js +0 -1
- package/dist/src/runtime/protocol-worker.js +0 -18
- package/dist/src/runtime/provider-bridge.js +0 -290
- package/dist/src/runtime/provider-credentials.js +0 -41
- package/dist/src/runtime/provider-transport.js +0 -406
- package/dist/src/runtime/runtime-broker.js +0 -213
- package/dist/src/runtime/workspace-instructions.js +0 -120
- package/dist/src/runtime/workspace-view.js +0 -74
- package/dist/src/server/api-contract.json +0 -11637
- package/dist/src/server/api-types.js +0 -1
- package/dist/src/server/application.js +0 -44
- package/dist/src/server/auth.js +0 -67
- package/dist/src/server/broker-handlers.js +0 -242
- package/dist/src/server/coding.js +0 -281
- package/dist/src/server/control-plane.js +0 -50
- package/dist/src/server/deployment.js +0 -249
- package/dist/src/server/errors.js +0 -22
- package/dist/src/server/history-handlers.js +0 -130
- package/dist/src/server/http.js +0 -124
- package/dist/src/server/paging.js +0 -56
- package/dist/src/server/publication.js +0 -119
- package/dist/src/server/tool-event-handler.js +0 -77
- package/dist/src/server/workspace-handlers.js +0 -34
- package/dist/src/storage/coordinator.js +0 -224
- package/dist/src/storage/startup-lock.js +0 -71
- package/dist/src/storage/store.js +0 -167
- package/dist/src/tools/check-worker.js +0 -81
- package/dist/src/tools/checks.js +0 -117
- package/dist/src/tools/command-check.js +0 -34
- package/dist/src/tools/commands.js +0 -312
- package/dist/src/tools/developer.js +0 -355
- package/dist/src/tools/dns.js +0 -248
- package/dist/src/tools/http-contract.js +0 -38
- package/dist/src/tools/http.js +0 -358
- package/dist/src/tools/index.js +0 -194
- package/dist/src/tools/worker-check.js +0 -73
- package/dist/src/workspaces/git.js +0 -227
- package/dist/src/workspaces/index.js +0 -937
- package/dist/src/workspaces/source.js +0 -295
- package/examples/deployment.local.json +0 -22
- package/scripts/postinstall.mjs +0 -26
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { chmodSync, closeSync, constants, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readlinkSync, readSync, realpathSync, renameSync, rmSync, rmdirSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from 'node:fs';
|
|
4
|
-
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
5
|
-
import { WorkspaceError } from './git.js';
|
|
6
|
-
export const DEFAULT_SOURCE_QUOTAS = { entries: 100_000, fileBytes: 1_073_741_824, totalBytes: 10_737_418_240 };
|
|
7
|
-
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
8
|
-
const stamp = (s) => `${s.dev}:${s.ino}:${s.mode}:${s.size}:${s.mtimeMs}:${s.ctimeMs}`;
|
|
9
|
-
export const within = (root, path) => path === root || (!relative(root, path).startsWith('..' + '/') && relative(root, path) !== '..' && !isAbsolute(relative(root, path)));
|
|
10
|
-
/** Engine-private content store. Large files are hashed/copied in fixed-size chunks. */
|
|
11
|
-
export class SourceBlobs {
|
|
12
|
-
directory;
|
|
13
|
-
constructor(directory) { this.directory = join(directory, 'blobs'); mkdirSync(this.directory, { recursive: true, mode: 0o700 }); }
|
|
14
|
-
path(id) { if (!/^[a-f0-9]{64}$/.test(id))
|
|
15
|
-
throw new WorkspaceError('invalid_source_blob'); return join(this.directory, id); }
|
|
16
|
-
put(bytes) { const id = sha(bytes), path = this.path(id); if (!existsSync(path))
|
|
17
|
-
writeFileSync(path, bytes, { mode: 0o600, flag: 'wx' }); return id; }
|
|
18
|
-
capture(path, limit) {
|
|
19
|
-
const input = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW), temporary = join(this.directory, randomUUID());
|
|
20
|
-
let output;
|
|
21
|
-
try {
|
|
22
|
-
const before = fstatSync(input);
|
|
23
|
-
if (!before.isFile() || before.size > limit)
|
|
24
|
-
throw new WorkspaceError('source_file_quota', 422);
|
|
25
|
-
output = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL, 0o600);
|
|
26
|
-
const hash = createHash('sha256'), objectHash = createHash('sha1').update(`blob ${before.size}\0`), buffer = Buffer.alloc(65_536);
|
|
27
|
-
let size = 0;
|
|
28
|
-
for (;;) {
|
|
29
|
-
const count = readSync(input, buffer, 0, buffer.length, null);
|
|
30
|
-
if (!count)
|
|
31
|
-
break;
|
|
32
|
-
size += count;
|
|
33
|
-
if (size > limit)
|
|
34
|
-
throw new WorkspaceError('source_file_quota', 422);
|
|
35
|
-
hash.update(buffer.subarray(0, count));
|
|
36
|
-
objectHash.update(buffer.subarray(0, count));
|
|
37
|
-
let written = 0;
|
|
38
|
-
while (written < count)
|
|
39
|
-
written += writeSync(output, buffer, written, count - written);
|
|
40
|
-
}
|
|
41
|
-
if (stamp(before) !== stamp(fstatSync(input)))
|
|
42
|
-
throw new WorkspaceError('workspace_changed_during_capture');
|
|
43
|
-
closeSync(output);
|
|
44
|
-
output = undefined;
|
|
45
|
-
const blob = hash.digest('hex'), target = this.path(blob);
|
|
46
|
-
if (existsSync(target))
|
|
47
|
-
unlinkSync(temporary);
|
|
48
|
-
else
|
|
49
|
-
renameSync(temporary, target);
|
|
50
|
-
return { blob, size, gitObject: objectHash.digest('hex') };
|
|
51
|
-
}
|
|
52
|
-
finally {
|
|
53
|
-
closeSync(input);
|
|
54
|
-
if (output !== undefined)
|
|
55
|
-
closeSync(output);
|
|
56
|
-
if (existsSync(temporary))
|
|
57
|
-
unlinkSync(temporary);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
bytes(entry) { return entry.blob ? readFileSync(this.path(entry.blob)) : Buffer.from(entry.data ?? '', 'base64'); }
|
|
61
|
-
}
|
|
62
|
-
/** Fixed Git operations; never run repository hooks, filters, credential helpers or model arguments. */
|
|
63
|
-
export class SourceRepository {
|
|
64
|
-
generatedPaths;
|
|
65
|
-
startupLockFd;
|
|
66
|
-
root;
|
|
67
|
-
gitDirectory;
|
|
68
|
-
commonDirectory;
|
|
69
|
-
identity;
|
|
70
|
-
environment;
|
|
71
|
-
constructor(root, expectedIdentity, generatedPaths = [], startupLockFd) {
|
|
72
|
-
this.generatedPaths = generatedPaths;
|
|
73
|
-
this.startupLockFd = startupLockFd;
|
|
74
|
-
this.root = realpathSync(root);
|
|
75
|
-
this.environment = { PATH: '/usr/bin:/bin', LC_ALL: 'C', GIT_TERMINAL_PROMPT: '0', GIT_OPTIONAL_LOCKS: '0', GIT_CONFIG_NOSYSTEM: '1', GIT_ALLOW_PROTOCOL: '',
|
|
76
|
-
GIT_NO_LAZY_FETCH: '1',
|
|
77
|
-
...(process.env.HOME ? { HOME: process.env.HOME } : {}), ...(process.env.XDG_CONFIG_HOME ? { XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME } : {}) };
|
|
78
|
-
if (this.git(['rev-parse', '--show-toplevel']).toString().trim() !== this.root)
|
|
79
|
-
throw new WorkspaceError('workspace_not_repository_root', 422);
|
|
80
|
-
this.gitDirectory = realpathSync(this.git(['rev-parse', '--absolute-git-dir']).toString().trim());
|
|
81
|
-
this.commonDirectory = realpathSync(resolve(this.root, this.git(['rev-parse', '--git-common-dir']).toString().trim()));
|
|
82
|
-
for (const path of [this.root, this.gitDirectory, this.commonDirectory]) {
|
|
83
|
-
const s = lstatSync(path);
|
|
84
|
-
if (!s.isDirectory() || s.uid !== process.geteuid?.() || (s.mode & 0o22))
|
|
85
|
-
throw new WorkspaceError('git_unsafe_permissions', 422);
|
|
86
|
-
}
|
|
87
|
-
const info = lstatSync(this.gitDirectory), common = lstatSync(this.commonDirectory);
|
|
88
|
-
this.identity = `${info.dev}:${info.ino}:${common.dev}:${common.ino}:${sha(this.gitDirectory + '\0' + this.commonDirectory)}`;
|
|
89
|
-
if (expectedIdentity !== undefined && this.identity !== expectedIdentity)
|
|
90
|
-
throw new WorkspaceError('workspace_git_identity_changed');
|
|
91
|
-
for (const name of ['index.lock', 'HEAD.lock', 'MERGE_HEAD', 'CHERRY_PICK_HEAD', 'REVERT_HEAD', 'rebase-merge', 'rebase-apply'])
|
|
92
|
-
if (existsSync(join(this.gitDirectory, name)))
|
|
93
|
-
throw new WorkspaceError('git_operation_in_progress');
|
|
94
|
-
}
|
|
95
|
-
git(args, input, output) {
|
|
96
|
-
const result = spawnSync('/usr/bin/git', ['--no-pager', '-C', this.root, '-c', 'core.hooksPath=/dev/null', '-c', 'core.fsmonitor=false', '-c', 'core.attributesFile=/dev/null',
|
|
97
|
-
'-c', 'diff.external=', '-c', 'commit.gpgSign=false', '-c', 'user.useConfigOnly=true', ...args], { env: this.environment, ...(input === undefined ? {} : { input }), timeout: 30_000, maxBuffer: 64 * 1_048_576, stdio: ['pipe', output ?? 'pipe', 'pipe', ...(this.startupLockFd === undefined ? [] : [this.startupLockFd])] });
|
|
98
|
-
if (result.error || result.status !== 0)
|
|
99
|
-
throw new WorkspaceError('git_operation_failed', 409, `Fixed Git operation ${args[0]} failed.`);
|
|
100
|
-
return Buffer.isBuffer(result.stdout) ? result.stdout : Buffer.alloc(0);
|
|
101
|
-
}
|
|
102
|
-
safePath(path, absent = false, follow = false, allowLink = false) {
|
|
103
|
-
if (!path || isAbsolute(path) || path.includes('\0') || path.includes('\\') || path.split('/').some(p => p === '..' || p.toLowerCase() === '.git'))
|
|
104
|
-
throw new WorkspaceError('invalid_source_path', 422);
|
|
105
|
-
const target = resolve(this.root, path);
|
|
106
|
-
if (target === this.root)
|
|
107
|
-
return this.root;
|
|
108
|
-
if (!within(this.root, target))
|
|
109
|
-
throw new WorkspaceError('invalid_source_path', 422);
|
|
110
|
-
let parent = dirname(target);
|
|
111
|
-
while (!existsSync(parent) && absent && parent !== this.root)
|
|
112
|
-
parent = dirname(parent);
|
|
113
|
-
const authorized = (actual) => within(this.root, actual) && !within(this.gitDirectory, actual) && !within(this.commonDirectory, actual);
|
|
114
|
-
const actualParent = realpathSync(parent);
|
|
115
|
-
if (!authorized(actualParent))
|
|
116
|
-
throw new WorkspaceError('source_path_escape', 403);
|
|
117
|
-
let targetInfo;
|
|
118
|
-
try {
|
|
119
|
-
targetInfo = lstatSync(target);
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
if (error.code !== 'ENOENT')
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
if (targetInfo?.isSymbolicLink()) {
|
|
126
|
-
if (allowLink && !follow)
|
|
127
|
-
return target;
|
|
128
|
-
if (!follow)
|
|
129
|
-
throw new WorkspaceError('source_symlink_requires_resolution', 403);
|
|
130
|
-
const actual = realpathSync(target);
|
|
131
|
-
if (!authorized(actual))
|
|
132
|
-
throw new WorkspaceError('source_path_escape', 403);
|
|
133
|
-
return actual;
|
|
134
|
-
}
|
|
135
|
-
return target;
|
|
136
|
-
}
|
|
137
|
-
head() { return this.object(this.git(['rev-parse', '--verify', 'HEAD']).toString().trim()); }
|
|
138
|
-
branch() { const value = this.git(['rev-parse', '--symbolic-full-name', 'HEAD']).toString().trim(); if (value !== 'HEAD' && !value.startsWith('refs/heads/'))
|
|
139
|
-
throw new WorkspaceError('unsupported_git_head'); return value; }
|
|
140
|
-
validateConfiguration() { return sha(this.git(['config', '--local', '--null', '--list'])); }
|
|
141
|
-
assertIdentity() { this.git(['var', 'GIT_AUTHOR_IDENT']); this.git(['var', 'GIT_COMMITTER_IDENT']); }
|
|
142
|
-
index() { const path = join(this.gitDirectory, 'index'), bytes = existsSync(path) ? readFileSync(path) : Buffer.alloc(0); return { identity: existsSync(path) ? stamp(lstatSync(path)) : 'absent', contentDigest: sha(bytes), bytes }; }
|
|
143
|
-
tree(commit) {
|
|
144
|
-
return this.git(['ls-tree', '-rz', this.object(commit)]).toString('utf8').split('\0').filter(Boolean).map(line => {
|
|
145
|
-
const match = /^(100644|100755|120000) blob ([a-f0-9]{40})\t([\s\S]+)$/.exec(line);
|
|
146
|
-
if (!match)
|
|
147
|
-
throw new WorkspaceError('unsupported_git_tree', 422);
|
|
148
|
-
return { path: match[3], object: match[2], mode: Number.parseInt(match[1], 8) };
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
indexEntries() { return this.git(['ls-files', '--stage', '-z']).toString().split('\0').filter(Boolean); }
|
|
152
|
-
sourceEntries() {
|
|
153
|
-
const tracked = this.git(['ls-files', '--cached', '-z']).toString('utf8').split('\0').filter(Boolean), untracked = this.git(['ls-files', '--others', '--exclude-standard', '-z']).toString('utf8').split('\0').filter(Boolean).filter(path => !this.generatedPaths.some(excluded => path === excluded || path.startsWith(excluded + '/')));
|
|
154
|
-
const names = [...new Set([...tracked, ...untracked])].sort();
|
|
155
|
-
const entries = new Map();
|
|
156
|
-
for (const path of names) {
|
|
157
|
-
if (path.split('/').some(p => p.toLowerCase() === '.git' || p === '..'))
|
|
158
|
-
throw new WorkspaceError('invalid_source_path');
|
|
159
|
-
let info;
|
|
160
|
-
try {
|
|
161
|
-
info = lstatSync(join(this.root, path));
|
|
162
|
-
}
|
|
163
|
-
catch (e) {
|
|
164
|
-
if (e.code === 'ENOENT')
|
|
165
|
-
continue;
|
|
166
|
-
throw e;
|
|
167
|
-
}
|
|
168
|
-
if (info.isFile() && info.nlink !== 1)
|
|
169
|
-
throw new WorkspaceError('unsafe_source_hardlink', 422);
|
|
170
|
-
if (!info.isFile() && !info.isSymbolicLink())
|
|
171
|
-
throw new WorkspaceError('unsupported_source_entry', 422);
|
|
172
|
-
if (info.uid !== process.geteuid?.() || (info.mode & 0o22))
|
|
173
|
-
throw new WorkspaceError('unsafe_source_permissions', 422);
|
|
174
|
-
const parent = realpathSync(dirname(join(this.root, path)));
|
|
175
|
-
if (!within(this.root, parent))
|
|
176
|
-
throw new WorkspaceError('source_path_escape');
|
|
177
|
-
entries.set(path, { path, type: info.isSymbolicLink() ? 'symlink' : 'file', identity: stamp(info), mode: info.mode & 0o777, size: info.size });
|
|
178
|
-
for (let dir = dirname(path); dir !== '.'; dir = dirname(dir)) {
|
|
179
|
-
const s = lstatSync(join(this.root, dir));
|
|
180
|
-
entries.set(dir, { path: dir, type: 'directory', mode: s.mode & 0o777, identity: `${s.dev}:${s.ino}:${s.mode}` });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return [...entries.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
184
|
-
}
|
|
185
|
-
capture(blobs, quotas) {
|
|
186
|
-
const entries = this.sourceEntries();
|
|
187
|
-
if (entries.length > quotas.entries)
|
|
188
|
-
throw new WorkspaceError('source_entry_quota', 422);
|
|
189
|
-
let total = 0;
|
|
190
|
-
const unique = new Set();
|
|
191
|
-
return entries.map(entry => {
|
|
192
|
-
if (entry.type === 'directory')
|
|
193
|
-
return entry;
|
|
194
|
-
const value = entry.type === 'symlink' ? { blob: blobs.put(Buffer.from(readlinkSync(join(this.root, entry.path)))), size: entry.size, gitObject: createHash('sha1').update(`blob ${entry.size}\0`).update(readlinkSync(join(this.root, entry.path))).digest('hex') } : blobs.capture(join(this.root, entry.path), quotas.fileBytes);
|
|
195
|
-
if (!unique.has(value.blob)) {
|
|
196
|
-
unique.add(value.blob);
|
|
197
|
-
total += value.size;
|
|
198
|
-
}
|
|
199
|
-
if (total > quotas.totalBytes)
|
|
200
|
-
throw new WorkspaceError('source_total_quota', 422);
|
|
201
|
-
return { ...entry, ...value, contentDigest: value.blob };
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
object(value) { if (!/^[a-f0-9]{40}$/.test(value))
|
|
205
|
-
throw new WorkspaceError('unsupported_git_object_format', 422); return value; }
|
|
206
|
-
blob(bytes) { return this.object(this.git(['hash-object', '-w', '--stdin', '--no-filters'], bytes).toString().trim()); }
|
|
207
|
-
makeTree(files) {
|
|
208
|
-
return this.manifestTree(files.map(f => ({ ...f, object: this.blob(f.bytes) })));
|
|
209
|
-
}
|
|
210
|
-
sourceTree(entries, blobs) {
|
|
211
|
-
const files = entries.filter(e => e.type !== 'directory'), ids = [...new Set(files.flatMap(e => e.gitObject ? [this.object(e.gitObject)] : []))];
|
|
212
|
-
const known = new Set(ids.length ? this.git(['cat-file', '--batch-check=%(objectname) %(objecttype)'], Buffer.from(ids.join('\n') + '\n')).toString().trim().split('\n').filter(line => line.endsWith(' blob')).map(line => line.split(' ')[0]) : []);
|
|
213
|
-
// Tracked content already exists in Git. Only new bytes need another
|
|
214
|
-
// object write; do not launch one Git process for every unchanged file.
|
|
215
|
-
return this.manifestTree(files.map(e => { const object = e.gitObject && known.has(e.gitObject) ? e.gitObject : e.blob ? this.object(this.git(['hash-object', '-w', '--no-filters', blobs.path(e.blob)]).toString().trim()) : this.blob(blobs.bytes(e)); if (e.gitObject)
|
|
216
|
-
known.add(e.gitObject); return { path: e.path, mode: e.type === 'symlink' ? 0o120000 : e.mode, object }; }));
|
|
217
|
-
}
|
|
218
|
-
manifestTree(files) {
|
|
219
|
-
const root = { files: [], dirs: new Map() };
|
|
220
|
-
for (const file of files) {
|
|
221
|
-
const parts = file.path.split('/');
|
|
222
|
-
let t = root;
|
|
223
|
-
for (const part of parts.slice(0, -1)) {
|
|
224
|
-
if (!t.dirs.has(part))
|
|
225
|
-
t.dirs.set(part, { files: [], dirs: new Map() });
|
|
226
|
-
t = t.dirs.get(part);
|
|
227
|
-
}
|
|
228
|
-
t.files.push({ name: parts.at(-1), object: file.object, mode: file.mode === 0o120000 ? 0o120000 : file.mode & 0o100 ? 0o100755 : 0o100644 });
|
|
229
|
-
}
|
|
230
|
-
const write = (t) => {
|
|
231
|
-
const records = [...t.files.map(f => ({ sort: f.name, line: `${f.mode.toString(8)} blob ${f.object}\t${f.name}\0` })), ...[...t.dirs].map(([name, child]) => ({ sort: name + '/', line: `040000 tree ${write(child)}\t${name}\0` }))].sort((a, b) => Buffer.compare(Buffer.from(a.sort), Buffer.from(b.sort)));
|
|
232
|
-
return this.object(this.git(['mktree', '-z'], Buffer.from(records.map(r => r.line).join(''))).toString().trim());
|
|
233
|
-
};
|
|
234
|
-
return write(root);
|
|
235
|
-
}
|
|
236
|
-
commit(tree, parent, message) { this.assertIdentity(); return this.object(this.git(['commit-tree', this.object(tree), '-p', this.object(parent)], Buffer.from(message)).toString().trim()); }
|
|
237
|
-
updateRef(ref, next, expected) { if (!ref.startsWith('refs/') || ref.includes('..'))
|
|
238
|
-
throw new WorkspaceError('invalid_git_ref'); this.git(['update-ref', ref, this.object(next), this.object(expected)]); }
|
|
239
|
-
installIndex(commit, expectedIdentity) { if (this.index().identity !== expectedIdentity)
|
|
240
|
-
throw new WorkspaceError('git_index_changed'); this.git(['read-tree', this.object(commit)]); }
|
|
241
|
-
restoreIndex(bytes) { const path = join(this.gitDirectory, 'index'), temporary = path + '.lock'; if (!bytes.length) {
|
|
242
|
-
rmSync(path, { force: true });
|
|
243
|
-
return;
|
|
244
|
-
} writeFileSync(temporary, bytes, { flag: 'wx', mode: 0o600 }); renameSync(temporary, path); }
|
|
245
|
-
restore(entries, observed, blobs) {
|
|
246
|
-
for (const entry of observed.filter(e => e.type !== 'directory' && !entries.some(t => t.path === e.path && t.type === e.type)))
|
|
247
|
-
unlinkSync(this.safePath(entry.path, false, false, true));
|
|
248
|
-
// Remove only emptied, run-created directories before restoring a file at
|
|
249
|
-
// the same path. Nonempty directories preserve conflicting ignored state.
|
|
250
|
-
for (const entry of observed.filter(e => e.type === 'directory' && !entries.some(t => t.path === e.path && t.type === 'directory')).sort((a, b) => b.path.length - a.path.length))
|
|
251
|
-
try {
|
|
252
|
-
rmdirSync(this.safePath(entry.path));
|
|
253
|
-
}
|
|
254
|
-
catch (e) {
|
|
255
|
-
if (!['ENOTEMPTY', 'EISDIR', 'ENOENT'].includes(e.code ?? ''))
|
|
256
|
-
throw e;
|
|
257
|
-
}
|
|
258
|
-
for (const entry of entries.filter(e => e.type === 'directory').sort((a, b) => a.path.length - b.path.length))
|
|
259
|
-
mkdirSync(this.safePath(entry.path, true), { recursive: true, mode: entry.mode });
|
|
260
|
-
for (const entry of entries.filter(e => e.type !== 'directory')) {
|
|
261
|
-
if (observed.some(e => e.path === entry.path && e.type === entry.type && e.mode === entry.mode && e.contentDigest === entry.contentDigest))
|
|
262
|
-
continue;
|
|
263
|
-
const target = join(this.root, entry.path);
|
|
264
|
-
this.safePath(dirname(entry.path), true);
|
|
265
|
-
if (existsSync(target) || (() => { try {
|
|
266
|
-
return lstatSync(target).isSymbolicLink();
|
|
267
|
-
}
|
|
268
|
-
catch {
|
|
269
|
-
return false;
|
|
270
|
-
} })()) {
|
|
271
|
-
const s = lstatSync(target);
|
|
272
|
-
if (s.isDirectory())
|
|
273
|
-
throw new WorkspaceError('source_restore_conflict');
|
|
274
|
-
unlinkSync(target);
|
|
275
|
-
}
|
|
276
|
-
if (entry.type === 'symlink')
|
|
277
|
-
symlinkSync(blobs.bytes(entry).toString(), target);
|
|
278
|
-
else {
|
|
279
|
-
if (entry.blob)
|
|
280
|
-
copyFileSync(blobs.path(entry.blob), target, constants.COPYFILE_EXCL);
|
|
281
|
-
else
|
|
282
|
-
writeFileSync(target, blobs.bytes(entry), { flag: 'wx' });
|
|
283
|
-
chmodSync(target, entry.mode);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
for (const entry of observed.filter(e => e.type === 'directory' && !entries.some(t => t.path === e.path)).sort((a, b) => b.path.length - a.path.length))
|
|
287
|
-
try {
|
|
288
|
-
rmdirSync(this.safePath(entry.path));
|
|
289
|
-
}
|
|
290
|
-
catch (e) {
|
|
291
|
-
if (!['ENOTEMPTY', 'EISDIR', 'ENOENT'].includes(e.code ?? ''))
|
|
292
|
-
throw e;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"listenPort": 31260,
|
|
3
|
-
"operator": {
|
|
4
|
-
"id": "local-operator",
|
|
5
|
-
"workspaceIds": ["*"]
|
|
6
|
-
},
|
|
7
|
-
"runtime": {
|
|
8
|
-
"enabled": false,
|
|
9
|
-
"executable": "/REPLACE_WITH_ABSOLUTE_PATH_TO_CODEX",
|
|
10
|
-
"modelPort": 31261,
|
|
11
|
-
"models": [
|
|
12
|
-
{ "id": "REPLACE_WITH_LOCAL_MODEL_ID", "effortLevels": ["low"] }
|
|
13
|
-
]
|
|
14
|
-
},
|
|
15
|
-
"deploymentPolicy": { "defaultEffect": "deny", "rules": [] },
|
|
16
|
-
"agentHttp": {},
|
|
17
|
-
"schemaHttp": {
|
|
18
|
-
"networkPolicy": { "defaultEffect": "deny", "rules": [] }
|
|
19
|
-
},
|
|
20
|
-
"checks": [],
|
|
21
|
-
"deploymentRoots": []
|
|
22
|
-
}
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
|
|
4
|
-
// Compile native macOS C helpers on npm/npx install without writing to stdout.
|
|
5
|
-
// In a source checkout before `npm run build`, `dist/` does not exist yet: exit quietly.
|
|
6
|
-
if (process.platform !== 'darwin') process.exit(0);
|
|
7
|
-
|
|
8
|
-
const nativeDir = new URL('../dist/src/broker/native/', import.meta.url);
|
|
9
|
-
const buildModule = new URL('build.js', nativeDir);
|
|
10
|
-
const fsSource = fileURLToPath(new URL('fs-helper.c', nativeDir));
|
|
11
|
-
const gitSource = fileURLToPath(new URL('git-helper.c', nativeDir));
|
|
12
|
-
|
|
13
|
-
if (!existsSync(fileURLToPath(buildModule)) || !existsSync(fsSource) || !existsSync(gitSource)) {
|
|
14
|
-
process.exit(0);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
process.umask(0o077);
|
|
18
|
-
try {
|
|
19
|
-
const { buildFilesystemHelper, buildGitHelper, buildCommandHelper } = await import(buildModule.href);
|
|
20
|
-
buildFilesystemHelper();
|
|
21
|
-
buildGitHelper();
|
|
22
|
-
buildCommandHelper();
|
|
23
|
-
} catch (error) {
|
|
24
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
25
|
-
process.stderr.write(`code60-transmission-server: native helper build skipped during install (${message}).\n`);
|
|
26
|
-
}
|