code60-transmission-server 0.1.0-staging.2 → 0.1.0

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 CHANGED
@@ -47,10 +47,6 @@ npx -y code60-transmission-server stop
47
47
  The default state directory and port (`31260`) are shared cleanly with the
48
48
  macOS `.pkg` installer below. Before changing `configuration.json` or upgrading
49
49
  to a new package version, let active runs finish, run `stop`, and reconnect.
50
- Registered workspaces must be standalone Git repositories prepared normally on
51
- disk (with a real `.git` directory, at least one commit, and no hardlinked
52
- `.git/objects` files—do not initialize repositories inside a sandbox that
53
- forbids deleting files, and use `git clone --no-hardlinks` for local clones).
54
50
 
55
51
  ## Install on macOS
56
52
 
@@ -16,12 +16,6 @@
16
16
  * No arbitrary executable, Git subcommand, option, path, environment or shell.
17
17
  * Effects additionally run under the Git driver's deny-default Seatbelt policy. */
18
18
  static void die(void) { fputs("git_helper_denied\n", stderr); exit(74); }
19
- static void die_reason(const char *reason) {
20
- fputs("git_helper_denied:", stderr);
21
- fputs(reason, stderr);
22
- fputc('\n', stderr);
23
- exit(74);
24
- }
25
19
  static int directory(int fd) {
26
20
  struct stat s;
27
21
  return fstat(fd, &s) == 0 && S_ISDIR(s.st_mode) && s.st_uid == geteuid() && !(s.st_mode & 022);
@@ -48,26 +42,21 @@ static int ref(const char *s) {
48
42
  }
49
43
  static unsigned entries;
50
44
  static void inspect(int fd, unsigned depth) {
51
- if (depth > 64) die_reason("too_complex");
52
- if (!directory(fd)) die_reason("unsafe_permissions");
45
+ if (depth > 64 || !directory(fd)) die();
53
46
  int copy = openat(fd, ".", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
54
47
  if (copy < 0) die();
55
48
  DIR *dir = fdopendir(copy); if (!dir) die();
56
49
  struct dirent *entry;
57
50
  while ((entry = readdir(dir))) {
58
51
  if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue;
59
- if (++entries > 100000) die_reason("too_complex");
52
+ if (++entries > 100000) die();
60
53
  struct stat s;
61
54
  if (fstatat(fd, entry->d_name, &s, AT_SYMLINK_NOFOLLOW) < 0) die();
62
55
  if (S_ISDIR(s.st_mode)) {
63
56
  int child = openat(fd, entry->d_name, O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
64
57
  if (child < 0) die();
65
58
  inspect(child, depth + 1); close(child);
66
- } else if (!regular(&s)) {
67
- if (!S_ISREG(s.st_mode)) die_reason("unsupported_file_type");
68
- if (s.st_nlink != 1) die_reason("hardlink");
69
- die_reason("unsafe_permissions");
70
- }
59
+ } else if (!regular(&s)) die();
71
60
  }
72
61
  closedir(dir);
73
62
  }
@@ -132,38 +121,20 @@ int main(int argc, char **argv) {
132
121
  }
133
122
  puts("locked"); return 0;
134
123
  }
135
- if (argc < 2 || argc > 7) die();
136
- if (!directory(3)) die_reason("unsafe_permissions");
124
+ if (argc < 2 || argc > 7 || !directory(3)) die();
137
125
  int git = openat(3, ".git", O_RDONLY | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
138
- if (git < 0) {
139
- if (errno == ENOENT) die_reason("missing_git_dir");
140
- if (errno == ENOTDIR || errno == ELOOP) die_reason("unsupported_worktree");
141
- die();
142
- }
143
- if (!directory(git)) die_reason("unsafe_permissions");
126
+ if (git < 0 || !directory(git)) die();
144
127
  struct stat s; if (fstat(git, &s) < 0) die();
145
128
  char git_id[128]; snprintf(git_id, sizeof(git_id), "%ju:%ju", (uintmax_t)s.st_dev, (uintmax_t)s.st_ino);
146
129
  if (!strcmp(argv[1], "probe") && argc == 2) { puts(git_id); return 0; }
147
130
  if (argc < 3 || strcmp(argv[2], git_id)) die();
148
131
  inspect(git, 0);
149
- const char *locks[] = {"index.lock", "HEAD.lock", "packed-refs.lock", NULL};
150
- for (size_t i = 0; locks[i]; i++) {
151
- struct stat feature;
152
- if (fstatat(git, locks[i], &feature, AT_SYMLINK_NOFOLLOW) == 0) die_reason("lock_file");
153
- if (errno != ENOENT) die();
154
- }
155
- const char *in_progress[] = {"MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD", "rebase-apply", "rebase-merge", "BISECT_LOG", NULL};
156
- for (size_t i = 0; in_progress[i]; i++) {
157
- struct stat feature;
158
- if (fstatat(git, in_progress[i], &feature, AT_SYMLINK_NOFOLLOW) == 0) die_reason("operation_in_progress");
159
- if (errno != ENOENT) die();
160
- }
161
132
  const char *unsupported[] = {"commondir", "shallow", "info/grafts", "objects/info/alternates", "objects/info/http-alternates",
162
- "info/sparse-checkout", "refs/replace", "worktrees", NULL};
133
+ "info/sparse-checkout", "refs/replace", "worktrees", "MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD",
134
+ "rebase-apply", "rebase-merge", "BISECT_LOG", "index.lock", "HEAD.lock", "packed-refs.lock", NULL};
163
135
  for (size_t i = 0; unsupported[i]; i++) {
164
136
  struct stat feature;
165
- if (fstatat(git, unsupported[i], &feature, AT_SYMLINK_NOFOLLOW) == 0) die_reason("unsupported_feature");
166
- if (errno != ENOENT) die();
137
+ if (fstatat(git, unsupported[i], &feature, AT_SYMLINK_NOFOLLOW) == 0 || errno != ENOENT) die();
167
138
  }
168
139
  if (!strcmp(argv[1], "config") && argc == 3) { read_file(git, "config", 0); return 0; }
169
140
  if (!strcmp(argv[1], "index") && argc == 3) { read_file(git, "index", 1); return 0; }
@@ -18,8 +18,7 @@ const resources = [
18
18
  ];
19
19
  const instructions = [
20
20
  'Operate the configured local Code60 Transmission Server with its operator workspace scope.',
21
- 'Discover runtimes and checks, register an authorized standalone Git repository, and publish profiles before workflows.',
22
- 'Workspaces must be existing standalone Git repositories with a real .git directory, at least one commit, no linked worktrees, no stale lock files, and no hardlinked files in .git. Do not run git init or git commit inside a sandbox that blocks file deletion (which leaves hardlinked tmp_obj_* files in .git); have the user prepare the repository directly on disk or clone with --no-hardlinks.',
21
+ 'Discover runtimes and checks, register an authorized worktree, and publish profiles before workflows.',
23
22
  'Use latestVersionId to pin profiles in workflow source and to select a workflow version in create_run.',
24
23
  'Read the workflow schema and example through resources/list and resources/read.',
25
24
  'POST tools take the engine request body under body and a caller-chosen idempotencyKey. Retry an uncertain outcome with the same arguments.',
@@ -44,7 +44,7 @@ export function createHttpServer(options) {
44
44
  app.setErrorHandler((error, request, reply) => {
45
45
  const framework = error && typeof error === 'object' ? error : {};
46
46
  const publicError = error instanceof ApiError ? error :
47
- (error instanceof BrokerError || error instanceof WorkspaceError) ? new ApiError(error.status, /^[a-z][a-z0-9_]{0,79}$/.test(error.code) ? error.code : 'service_error', error instanceof WorkspaceError && error.detail ? error.detail : 'The requested state transition is not permitted.') :
47
+ (error instanceof BrokerError || error instanceof WorkspaceError) ? new ApiError(error.status, /^[a-z][a-z0-9_]{0,79}$/.test(error.code) ? error.code : 'service_error', 'The requested state transition is not permitted.') :
48
48
  framework.code === 'FST_ERR_CTP_BODY_TOO_LARGE' ? new ApiError(413, 'payload_too_large', 'Request body exceeds the configured size limit.') :
49
49
  framework.statusCode === 400 || framework.statusCode === 415 ? new ApiError(framework.statusCode, 'invalid_request', 'Request encoding or structure is invalid.') :
50
50
  new ApiError(500, 'internal_error', 'The request could not be completed.');
@@ -6,61 +6,12 @@ import { startupLockIdentity } from "../broker/startup-lock.js";
6
6
  export class WorkspaceError extends Error {
7
7
  code;
8
8
  status;
9
- detail;
10
- constructor(code, status = 409, detail) {
9
+ constructor(code, status = 409) {
11
10
  super(code);
12
11
  this.code = code;
13
12
  this.status = status;
14
- this.detail = detail;
15
13
  }
16
14
  }
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
15
  const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
65
16
  const quote = (value) => `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
66
17
  const ancestors = (path) => path === dirname(path) ? [path] : [path, ...ancestors(dirname(path))];
@@ -132,23 +83,8 @@ export class WorkspaceGit {
132
83
  ...(this.options.startupLockFd === undefined ? [] : [this.options.startupLockFd])], env: this.environment,
133
84
  cwd: this.options.repositoryPath, timeout: 5000, maxBuffer: 16 * 1_048_576,
134
85
  });
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
- }
86
+ if (result.error || result.status !== 0 || result.signal)
87
+ throw new WorkspaceError(verb === "identity" || verb === "committer" ? "git_identity_unconfigured" : "git_operation_failed");
152
88
  return result.stdout;
153
89
  }
154
90
  validateConfiguration() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code60-transmission-server",
3
- "version": "0.1.0-staging.2",
3
+ "version": "0.1.0",
4
4
  "description": "Local workflow server and stdio MCP launcher for bounded coding-agent steps against Git workspaces.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [