code60-transmission-server 0.1.0-staging.12 → 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 -734
- 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 -1862
- 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 -11629
- 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 -127
- 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 -353
- 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,227 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
-
import { fstatSync, lstatSync } from "node:fs";
|
|
4
|
-
import { dirname, isAbsolute, join } from "node:path";
|
|
5
|
-
import { startupLockIdentity } from "../broker/startup-lock.js";
|
|
6
|
-
export class WorkspaceError extends Error {
|
|
7
|
-
code;
|
|
8
|
-
status;
|
|
9
|
-
detail;
|
|
10
|
-
constructor(code, status = 409, detail) {
|
|
11
|
-
super(code);
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.status = status;
|
|
14
|
-
this.detail = detail;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const DENIED_REASONS = {
|
|
18
|
-
missing_git_dir: {
|
|
19
|
-
code: "git_directory_missing",
|
|
20
|
-
status: 422,
|
|
21
|
-
detail: "Repository path does not contain a standalone .git directory.",
|
|
22
|
-
},
|
|
23
|
-
unsupported_worktree: {
|
|
24
|
-
code: "git_unsupported_worktree",
|
|
25
|
-
status: 422,
|
|
26
|
-
detail: "Repository .git must be a real directory, not a symlink or linked git worktree file.",
|
|
27
|
-
},
|
|
28
|
-
unsafe_permissions: {
|
|
29
|
-
code: "git_unsafe_permissions",
|
|
30
|
-
status: 422,
|
|
31
|
-
detail: "Repository and .git contents must be owned by the current user and not group- or world-writable.",
|
|
32
|
-
},
|
|
33
|
-
hardlink: {
|
|
34
|
-
code: "git_hardlinked_file",
|
|
35
|
-
status: 422,
|
|
36
|
-
detail: "Repository .git contains hardlinked files (st_nlink > 1), such as leftover tmp_obj_* files from a no-delete sandbox or a local hardlinked git clone. Remove leftover tmp_obj_* files or clone with --no-hardlinks.",
|
|
37
|
-
},
|
|
38
|
-
unsupported_file_type: {
|
|
39
|
-
code: "git_unsupported_file_type",
|
|
40
|
-
status: 422,
|
|
41
|
-
detail: "Repository .git contains a symlink or non-regular file.",
|
|
42
|
-
},
|
|
43
|
-
too_complex: {
|
|
44
|
-
code: "git_repository_too_complex",
|
|
45
|
-
status: 422,
|
|
46
|
-
detail: "Repository .git directory exceeds maximum depth or entry count limits.",
|
|
47
|
-
},
|
|
48
|
-
lock_file: {
|
|
49
|
-
code: "git_lock_file_present",
|
|
50
|
-
status: 409,
|
|
51
|
-
detail: "Repository .git contains a lock file (index.lock, HEAD.lock, or packed-refs.lock). Wait for other Git commands to finish or remove stale lock files.",
|
|
52
|
-
},
|
|
53
|
-
operation_in_progress: {
|
|
54
|
-
code: "git_operation_in_progress",
|
|
55
|
-
status: 409,
|
|
56
|
-
detail: "Repository has an unfinished Git merge, rebase, cherry-pick, revert, or bisect in progress.",
|
|
57
|
-
},
|
|
58
|
-
unsupported_feature: {
|
|
59
|
-
code: "git_unsupported_repository_feature",
|
|
60
|
-
status: 422,
|
|
61
|
-
detail: "Repository uses an unsupported Git feature (such as linked worktrees, shallow clone, alternates, grafts, replace refs, or sparse-checkout).",
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
65
|
-
const quote = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
66
|
-
const ancestors = (path) => path === dirname(path) ? [path] : [path, ...ancestors(dirname(path))];
|
|
67
|
-
/** Fixed local bare-plumbing interface. No working-tree checkout/add/filter,
|
|
68
|
-
* shell, network, credential helper, hook, signing or repository command. */
|
|
69
|
-
export class WorkspaceGit {
|
|
70
|
-
options;
|
|
71
|
-
identity;
|
|
72
|
-
environment;
|
|
73
|
-
profile;
|
|
74
|
-
lockIdentity;
|
|
75
|
-
constructor(options) {
|
|
76
|
-
this.options = options;
|
|
77
|
-
this.lockIdentity = options.startupLockFd === undefined ? undefined : startupLockIdentity(options.startupLockFd);
|
|
78
|
-
if (!isAbsolute(options.helperPath))
|
|
79
|
-
throw new WorkspaceError("untrusted_git_helper", 422);
|
|
80
|
-
const executable = lstatSync(options.helperPath);
|
|
81
|
-
if (!executable.isFile() || executable.isSymbolicLink() || executable.uid !== process.geteuid?.() ||
|
|
82
|
-
executable.nlink !== 1 || (executable.mode & 0o6022))
|
|
83
|
-
throw new WorkspaceError("untrusted_git_helper", 422);
|
|
84
|
-
const root = fstatSync(options.rootFd);
|
|
85
|
-
if (!root.isDirectory())
|
|
86
|
-
throw new WorkspaceError("workspace_identity_changed");
|
|
87
|
-
this.environment = { PATH: "/usr/bin:/bin", LC_ALL: "C", TZ: "UTC", GIT_TERMINAL_PROMPT: "0",
|
|
88
|
-
GIT_CONFIG_NOSYSTEM: "1", GIT_OPTIONAL_LOCKS: "0", GIT_ALLOW_PROTOCOL: "" };
|
|
89
|
-
// Preserve configured identity unchanged. Never supply invented user.*, -c
|
|
90
|
-
// identity, or changed GIT_AUTHOR/COMMITTER identity environment variables.
|
|
91
|
-
for (const name of ["HOME", "XDG_CONFIG_HOME", "GIT_AUTHOR_NAME", "GIT_AUTHOR_EMAIL", "GIT_COMMITTER_NAME", "GIT_COMMITTER_EMAIL"]) {
|
|
92
|
-
if (process.env[name] !== undefined)
|
|
93
|
-
this.environment[name] = process.env[name];
|
|
94
|
-
}
|
|
95
|
-
const probed = this.raw("probe", [], undefined, false).toString("utf8").trim();
|
|
96
|
-
if (!/^\d+:\d+$/.test(probed) || (options.expectedIdentity !== undefined && probed !== options.expectedIdentity)) {
|
|
97
|
-
throw new WorkspaceError("workspace_git_identity_changed");
|
|
98
|
-
}
|
|
99
|
-
this.identity = probed;
|
|
100
|
-
const git = join(options.repositoryPath, ".git");
|
|
101
|
-
const globalConfigs = this.environment.HOME ? [join(this.environment.HOME, ".gitconfig"),
|
|
102
|
-
join(this.environment.XDG_CONFIG_HOME ?? join(this.environment.HOME, ".config"), "git", "config")] : [];
|
|
103
|
-
const metadata = [...new Set([...ancestors(options.repositoryPath), ...globalConfigs.flatMap(ancestors),
|
|
104
|
-
...ancestors(options.helperPath), "/etc", "/private/etc", "/private/var", "/dev"])];
|
|
105
|
-
this.profile = `(version 1)
|
|
106
|
-
(deny default)
|
|
107
|
-
(allow process-fork)
|
|
108
|
-
(allow process-info* (target same-sandbox))
|
|
109
|
-
(allow signal (target same-sandbox))
|
|
110
|
-
(allow sysctl-read)
|
|
111
|
-
(allow mach-lookup (global-name "com.apple.system.opendirectoryd.libinfo"))
|
|
112
|
-
(allow file-read-metadata file-test-existence ${metadata.map(path => `(literal ${quote(path)})`).join(" ")})
|
|
113
|
-
(allow file-read* file-test-existence (literal "/") (subpath "/usr") (subpath "/bin")
|
|
114
|
-
(subpath "/System")
|
|
115
|
-
(subpath "/Library/Developer/CommandLineTools") (subpath "/private/var/db/dyld")
|
|
116
|
-
(literal "/dev/null") (literal "/dev/urandom") (literal "/dev/random")
|
|
117
|
-
(literal ${quote(options.repositoryPath)}) (subpath ${quote(git)})
|
|
118
|
-
(literal ${quote(options.helperPath)}) ${globalConfigs.map(path => `(literal ${quote(path)})`).join(" ")})
|
|
119
|
-
(allow file-write* (subpath ${quote(git)}) (literal "/dev/null"))
|
|
120
|
-
(allow process-exec (literal ${quote(options.helperPath)})
|
|
121
|
-
(literal "/Library/Developer/CommandLineTools/usr/bin/git"))
|
|
122
|
-
`;
|
|
123
|
-
this.validateConfiguration();
|
|
124
|
-
}
|
|
125
|
-
raw(verb, args = [], input, contained = true) {
|
|
126
|
-
if (this.options.startupLockFd !== undefined && startupLockIdentity(this.options.startupLockFd) !== this.lockIdentity) {
|
|
127
|
-
throw new WorkspaceError("startup_lock_changed");
|
|
128
|
-
}
|
|
129
|
-
const argv = [verb, ...(verb === "probe" ? [] : [this.identity]), ...args];
|
|
130
|
-
const result = spawnSync(contained ? "/usr/bin/sandbox-exec" : this.options.helperPath, contained ? ["-p", this.profile, this.options.helperPath, ...argv] : argv, {
|
|
131
|
-
input, stdio: ["pipe", "pipe", "pipe", this.options.rootFd,
|
|
132
|
-
...(this.options.startupLockFd === undefined ? [] : [this.options.startupLockFd])], env: this.environment,
|
|
133
|
-
cwd: this.options.repositoryPath, timeout: 5000, maxBuffer: 16 * 1_048_576,
|
|
134
|
-
});
|
|
135
|
-
if (result.error || result.status !== 0 || result.signal) {
|
|
136
|
-
if (result.status === 74 && result.stderr) {
|
|
137
|
-
const match = /^git_helper_denied:([a-z_]+)$/.exec(result.stderr.toString("utf8").trim());
|
|
138
|
-
const reason = match?.[1];
|
|
139
|
-
if (reason && Object.hasOwn(DENIED_REASONS, reason)) {
|
|
140
|
-
const mapped = DENIED_REASONS[reason];
|
|
141
|
-
throw new WorkspaceError(mapped.code, mapped.status, mapped.detail);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (verb === "identity" || verb === "committer") {
|
|
145
|
-
throw new WorkspaceError("git_identity_unconfigured", 409, "Git author/committer identity is not configured for this user.");
|
|
146
|
-
}
|
|
147
|
-
if (verb === "head" && result.status === 128) {
|
|
148
|
-
throw new WorkspaceError("git_head_unborn", 422, "Repository HEAD does not point to a commit yet. Create at least one commit before registering the workspace.");
|
|
149
|
-
}
|
|
150
|
-
throw new WorkspaceError("git_operation_failed");
|
|
151
|
-
}
|
|
152
|
-
return result.stdout;
|
|
153
|
-
}
|
|
154
|
-
validateConfiguration() {
|
|
155
|
-
const config = this.raw("config", [], undefined, false).toString("utf8");
|
|
156
|
-
if (/^\s*\[\s*(?:include|includeif|filter|extensions)\b/im.test(config) ||
|
|
157
|
-
/^\s*(?:worktree|gitproxy|sshcommand)\s*=/im.test(config) ||
|
|
158
|
-
config.split("\n").some(line => {
|
|
159
|
-
const match = /^\s*(?:bare|sharedrepository|fsmonitor)\s*=\s*(.*)$/i.exec(line);
|
|
160
|
-
return match && !/^(?:false|0|no|off)$/i.test(match[1].trim());
|
|
161
|
-
})) {
|
|
162
|
-
throw new WorkspaceError("unsupported_git_configuration", 422);
|
|
163
|
-
}
|
|
164
|
-
return hash(config);
|
|
165
|
-
}
|
|
166
|
-
head() { return this.object(this.raw("head").toString("ascii").trim()); }
|
|
167
|
-
branch() {
|
|
168
|
-
const ref = this.raw("branch").toString("utf8").trim();
|
|
169
|
-
if (!/^refs\/heads\/[A-Za-z0-9][A-Za-z0-9/_.-]*$/.test(ref) || ref.includes(".."))
|
|
170
|
-
throw new WorkspaceError("unsupported_git_head", 422);
|
|
171
|
-
return ref;
|
|
172
|
-
}
|
|
173
|
-
assertIdentity() { this.raw("identity"); this.raw("committer"); }
|
|
174
|
-
index() {
|
|
175
|
-
const result = this.raw("index", [], undefined, false), newline = result.indexOf(10);
|
|
176
|
-
if (newline < 0)
|
|
177
|
-
throw new WorkspaceError("git_index_unavailable");
|
|
178
|
-
return { identity: result.subarray(0, newline).toString("ascii"), bytes: result.subarray(newline + 1),
|
|
179
|
-
contentDigest: hash(result.subarray(newline + 1)) };
|
|
180
|
-
}
|
|
181
|
-
tree(commit) {
|
|
182
|
-
const entries = this.raw("ls-tree", [this.object(commit)]).toString("utf8").split("\0").filter(Boolean);
|
|
183
|
-
return entries.map(entry => {
|
|
184
|
-
const match = /^(100644|100755) blob ([a-f0-9]{40})\t([\s\S]+)$/.exec(entry);
|
|
185
|
-
if (!match)
|
|
186
|
-
throw new WorkspaceError("unsupported_git_tree", 422);
|
|
187
|
-
return { path: match[3], object: match[2], mode: Number.parseInt(match[1], 8) };
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
indexEntries() { return this.raw("index-tree").toString("utf8").split("\0").filter(Boolean); }
|
|
191
|
-
blob(bytes) { return this.object(this.raw("hash", [], bytes).toString("ascii").trim()); }
|
|
192
|
-
makeTree(files) {
|
|
193
|
-
const root = { files: [], directories: new Map() };
|
|
194
|
-
for (const file of files) {
|
|
195
|
-
const parts = file.path.split("/");
|
|
196
|
-
let tree = root;
|
|
197
|
-
for (const part of parts.slice(0, -1)) {
|
|
198
|
-
if (!tree.directories.has(part))
|
|
199
|
-
tree.directories.set(part, { files: [], directories: new Map() });
|
|
200
|
-
tree = tree.directories.get(part);
|
|
201
|
-
}
|
|
202
|
-
tree.files.push({ name: parts.at(-1), object: this.blob(file.bytes), mode: file.mode & 0o100 ? 0o100755 : 0o100644 });
|
|
203
|
-
}
|
|
204
|
-
const write = (tree) => {
|
|
205
|
-
const records = [...tree.files.map(file => ({ name: file.name, data: `${file.mode.toString(8)} blob ${file.object}\t${file.name}\0` })),
|
|
206
|
-
...[...tree.directories].map(([name, child]) => ({ name: `${name}/`, data: `040000 tree ${write(child)}\t${name}\0` }))];
|
|
207
|
-
records.sort((a, b) => Buffer.compare(Buffer.from(a.name), Buffer.from(b.name)));
|
|
208
|
-
return this.object(this.raw("tree", [], Buffer.from(records.map(record => record.data).join(""))).toString("ascii").trim());
|
|
209
|
-
};
|
|
210
|
-
return write(root);
|
|
211
|
-
}
|
|
212
|
-
commit(tree, parent, message) {
|
|
213
|
-
this.assertIdentity();
|
|
214
|
-
return this.object(this.raw("commit", [this.object(tree), this.object(parent)], Buffer.from(message)).toString("ascii").trim());
|
|
215
|
-
}
|
|
216
|
-
updateRef(ref, next, expected) { this.raw("ref", [ref, this.object(next), this.object(expected)]); }
|
|
217
|
-
installIndex(commit, expectedIdentity) {
|
|
218
|
-
const token = randomUUID();
|
|
219
|
-
this.raw("read-tree", [this.object(commit), token]);
|
|
220
|
-
this.raw("install-index", [token, expectedIdentity]);
|
|
221
|
-
}
|
|
222
|
-
object(value) {
|
|
223
|
-
if (!/^[a-f0-9]{40}$/.test(value))
|
|
224
|
-
throw new WorkspaceError("unsupported_git_object_format", 422);
|
|
225
|
-
return value;
|
|
226
|
-
}
|
|
227
|
-
}
|