code60-transmission-server 0.1.0 → 0.1.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.
Files changed (95) hide show
  1. package/INTENT.md +47 -0
  2. package/README.md +87 -240
  3. package/dist/src/acp.js +130 -0
  4. package/dist/src/contract.js +133 -0
  5. package/dist/src/engine.js +650 -0
  6. package/dist/src/linux.js +84 -0
  7. package/dist/src/main.js +81 -22
  8. package/dist/src/repository.js +94 -0
  9. package/dist/src/service.js +196 -0
  10. package/package.json +19 -33
  11. package/reference/openapi.json +1073 -0
  12. package/README.engine.md +0 -401
  13. package/dist/src/broker/filesystem.js +0 -385
  14. package/dist/src/broker/index.js +0 -734
  15. package/dist/src/broker/native/README.md +0 -192
  16. package/dist/src/broker/native/build.js +0 -43
  17. package/dist/src/broker/native/fs-helper.c +0 -529
  18. package/dist/src/broker/native/git-helper.c +0 -176
  19. package/dist/src/broker/policy.js +0 -149
  20. package/dist/src/broker/startup-lock.js +0 -14
  21. package/dist/src/broker/types.js +0 -11
  22. package/dist/src/cli/daemon.js +0 -365
  23. package/dist/src/cli/helpers.js +0 -104
  24. package/dist/src/cli/main.js +0 -180
  25. package/dist/src/config/deployment.js +0 -163
  26. package/dist/src/config/documents.js +0 -29
  27. package/dist/src/config/profile-validation.js +0 -123
  28. package/dist/src/config/schema-graph.js +0 -237
  29. package/dist/src/config/schema-loader.js +0 -185
  30. package/dist/src/config/validation-pool.js +0 -105
  31. package/dist/src/config/validation-protocol.js +0 -1
  32. package/dist/src/config/validation-worker.js +0 -106
  33. package/dist/src/config/workflow-language.js +0 -9
  34. package/dist/src/config/workflow-schema.json +0 -534
  35. package/dist/src/config/workflow-types.js +0 -1
  36. package/dist/src/config/workflow-validation.js +0 -95
  37. package/dist/src/engine/budgets.js +0 -50
  38. package/dist/src/engine/clocks.js +0 -27
  39. package/dist/src/engine/commands.js +0 -441
  40. package/dist/src/engine/contracts.js +0 -11
  41. package/dist/src/engine/drain-state.js +0 -31
  42. package/dist/src/engine/effective-permissions.js +0 -120
  43. package/dist/src/engine/instruction-pins.js +0 -205
  44. package/dist/src/engine/retries.js +0 -50
  45. package/dist/src/engine/state.js +0 -1
  46. package/dist/src/engine/timing.js +0 -23
  47. package/dist/src/engine/tool-observations.js +0 -87
  48. package/dist/src/engine/workflow-engine.js +0 -1807
  49. package/dist/src/mcp/catalog.js +0 -71
  50. package/dist/src/mcp/main.js +0 -24
  51. package/dist/src/mcp/server.js +0 -103
  52. package/dist/src/runtime/codex-app-server.js +0 -91
  53. package/dist/src/runtime/containment.js +0 -82
  54. package/dist/src/runtime/engine-driver.js +0 -212
  55. package/dist/src/runtime/json-line-writer.js +0 -192
  56. package/dist/src/runtime/pinned-instruction-sources.js +0 -24
  57. package/dist/src/runtime/protocol-client.js +0 -264
  58. package/dist/src/runtime/protocol-pool.js +0 -183
  59. package/dist/src/runtime/protocol-projection.js +0 -393
  60. package/dist/src/runtime/protocol-types.js +0 -1
  61. package/dist/src/runtime/protocol-worker.js +0 -18
  62. package/dist/src/runtime/provider-bridge.js +0 -288
  63. package/dist/src/runtime/provider-credentials.js +0 -41
  64. package/dist/src/runtime/provider-transport.js +0 -404
  65. package/dist/src/runtime/runtime-broker.js +0 -213
  66. package/dist/src/runtime/workspace-instructions.js +0 -120
  67. package/dist/src/runtime/workspace-view.js +0 -74
  68. package/dist/src/server/api-contract.json +0 -11078
  69. package/dist/src/server/api-types.js +0 -1
  70. package/dist/src/server/application.js +0 -38
  71. package/dist/src/server/auth.js +0 -67
  72. package/dist/src/server/broker-handlers.js +0 -242
  73. package/dist/src/server/control-plane.js +0 -50
  74. package/dist/src/server/deployment.js +0 -237
  75. package/dist/src/server/errors.js +0 -22
  76. package/dist/src/server/history-handlers.js +0 -113
  77. package/dist/src/server/http.js +0 -124
  78. package/dist/src/server/paging.js +0 -56
  79. package/dist/src/server/publication.js +0 -119
  80. package/dist/src/server/tool-event-handler.js +0 -77
  81. package/dist/src/server/workspace-handlers.js +0 -34
  82. package/dist/src/storage/coordinator.js +0 -224
  83. package/dist/src/storage/startup-lock.js +0 -71
  84. package/dist/src/storage/store.js +0 -167
  85. package/dist/src/tools/check-worker.js +0 -81
  86. package/dist/src/tools/checks.js +0 -106
  87. package/dist/src/tools/dns.js +0 -248
  88. package/dist/src/tools/http-contract.js +0 -38
  89. package/dist/src/tools/http.js +0 -358
  90. package/dist/src/tools/index.js +0 -177
  91. package/dist/src/tools/worker-check.js +0 -73
  92. package/dist/src/workspaces/git.js +0 -163
  93. package/dist/src/workspaces/index.js +0 -715
  94. package/examples/deployment.local.json +0 -22
  95. package/scripts/postinstall.mjs +0 -25
@@ -1,120 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync, realpathSync, } from 'node:fs';
3
- import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
- const defaultLimits = {
5
- maxDirectories: 10_000, maxFiles: 256, maxFileBytes: 1_048_576,
6
- };
7
- const filenames = ['AGENTS.override.md', 'AGENTS.md'];
8
- const hash = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
9
- function within(root, path) {
10
- const pathRelative = relative(root, path);
11
- if (isAbsolute(pathRelative) || pathRelative === '..' || pathRelative.startsWith('..' + sep)) {
12
- throw new Error('Instruction discovery escapes the approved workspace');
13
- }
14
- return pathRelative.split(sep).join('/');
15
- }
16
- /**
17
- * Snapshot workspace-only standard instruction names before an agent starts.
18
- * No global home, ancestor, fallback-name, plugin or skill discovery occurs.
19
- * The snapshot, not subsequent host files, is used for recovery/continuation.
20
- */
21
- export function pinWorkspaceInstructions(workspace, configuredLimits = {}) {
22
- const root = realpathSync(workspace);
23
- if (!lstatSync(root).isDirectory())
24
- throw new Error('Workspace must be a directory');
25
- const limits = { ...defaultLimits, ...configuredLimits };
26
- for (const value of Object.values(limits)) {
27
- if (!Number.isSafeInteger(value) || value <= 0)
28
- throw new Error('Instruction limits must be positive integers');
29
- }
30
- const files = [];
31
- let visited = 0;
32
- function scan(directory, ancestors) {
33
- if (++visited > limits.maxDirectories)
34
- throw new Error('Instruction directory limit exceeded');
35
- const actualDirectory = realpathSync(directory);
36
- within(root, actualDirectory);
37
- if (ancestors.has(actualDirectory))
38
- throw new Error('Instruction directory alias cycle');
39
- const nextAncestors = new Set([...ancestors, actualDirectory]);
40
- const entries = readdirSync(directory, { withFileTypes: true });
41
- const names = new Set(entries.map(entry => entry.name));
42
- let selected = false;
43
- for (const name of filenames) {
44
- if (!names.has(name))
45
- continue;
46
- if (files.length >= limits.maxFiles)
47
- throw new Error('Instruction file limit exceeded');
48
- const path = join(directory, name);
49
- const actualPath = realpathSync(path);
50
- const resolvedPath = within(root, actualPath);
51
- const fd = openSync(actualPath, constants.O_RDONLY | constants.O_NOFOLLOW);
52
- try {
53
- const before = fstatSync(fd, { bigint: true });
54
- if (!before.isFile() || before.nlink !== 1n)
55
- throw new Error('Instruction must be a non-hardlinked regular file');
56
- if (before.size > BigInt(limits.maxFileBytes))
57
- throw new Error('Instruction byte limit exceeded');
58
- const buffer = Buffer.alloc(limits.maxFileBytes + 1);
59
- let length = 0;
60
- while (length < buffer.length) {
61
- const count = readSync(fd, buffer, length, buffer.length - length, null);
62
- if (count === 0)
63
- break;
64
- length += count;
65
- }
66
- const bytes = buffer.subarray(0, length);
67
- const after = fstatSync(fd, { bigint: true });
68
- if (after.mtimeNs !== before.mtimeNs || after.ctimeNs !== before.ctimeNs ||
69
- after.size !== before.size || bytes.length > limits.maxFileBytes ||
70
- realpathSync(path) !== actualPath) {
71
- throw new Error('Instruction changed during pinning');
72
- }
73
- const content = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
74
- const active = !selected && content.trim().length > 0;
75
- if (active)
76
- selected = true;
77
- files.push(Object.freeze({
78
- path: within(root, path), resolvedPath, content, sha256: hash(content), selected: active,
79
- }));
80
- }
81
- finally {
82
- closeSync(fd);
83
- }
84
- }
85
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name, 'en'))) {
86
- if (entry.name === '.git' || filenames.includes(entry.name))
87
- continue;
88
- const child = join(directory, entry.name);
89
- if (entry.isDirectory())
90
- scan(child, nextAncestors);
91
- else if (entry.isSymbolicLink()) {
92
- const actualChild = realpathSync(child);
93
- const childRelative = relative(root, actualChild);
94
- if (isAbsolute(childRelative) || childRelative === '..' || childRelative.startsWith('..' + sep))
95
- continue;
96
- if (lstatSync(actualChild).isDirectory())
97
- scan(child, nextAncestors);
98
- }
99
- }
100
- }
101
- scan(root, new Set());
102
- files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
103
- const pinned = Object.freeze(files);
104
- return Object.freeze({ files: pinned, digest: hash(JSON.stringify(pinned)) });
105
- }
106
- /** Ancestor order is root to most-specific, with override winning per directory. */
107
- export function instructionsForWorkspacePath(snapshot, workspaceRelativePath) {
108
- if (isAbsolute(workspaceRelativePath))
109
- throw new Error('Expected a workspace-relative path');
110
- const normalized = relative('/', resolve('/', workspaceRelativePath)).split(sep).join('/');
111
- if (workspaceRelativePath.split(/[\\/]/u).includes('..'))
112
- throw new Error('Instruction target escapes workspace');
113
- const targetDirectory = dirname(normalized).split(sep).join('/');
114
- return snapshot.files.filter(file => {
115
- if (!file.selected)
116
- return false;
117
- const directory = dirname(file.path);
118
- return directory === '.' || directory === targetDirectory || targetDirectory.startsWith(directory + '/');
119
- }).sort((a, b) => a.path.split('/').length - b.path.split('/').length);
120
- }
@@ -1,74 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { lstatSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs';
3
- import { basename, dirname, isAbsolute, join } from 'node:path';
4
- import { instructionsForWorkspacePath } from './workspace-instructions.js';
5
- const hash = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
6
- /** A new instruction-only view, never the managed project or writable runtime home. */
7
- export function verifyWorkspaceInstructionSnapshot(snapshot) {
8
- // EngineStore canonicalizes object keys. Restore the producers' signed field
9
- // order after persistence, retaining every extra field in the digest too.
10
- const files = snapshot.files.map(({ path, resolvedPath, content, sha256, selected, ...rest }) => ({ path, resolvedPath, content, sha256, selected, ...rest }));
11
- if (hash(JSON.stringify(files)) !== snapshot.digest)
12
- throw new Error('Instruction snapshot digest mismatch');
13
- const paths = new Set();
14
- for (const file of snapshot.files) {
15
- if (isAbsolute(file.path) || file.path.includes('\\') ||
16
- file.path.split('/').some(part => !part || part === '.' || part === '..') ||
17
- !['AGENTS.md', 'AGENTS.override.md'].includes(basename(file.path)) ||
18
- paths.has(file.path) || hash(file.content) !== file.sha256) {
19
- throw new Error('Invalid pinned instruction entry');
20
- }
21
- paths.add(file.path);
22
- const selectedFile = ['AGENTS.override.md', 'AGENTS.md'].map(name => snapshot.files.find(other => dirname(other.path) === dirname(file.path) &&
23
- basename(other.path) === name && other.content.trim().length > 0)).find(Boolean);
24
- const selected = file.path === selectedFile?.path;
25
- if (file.selected !== selected)
26
- throw new Error('Instruction precedence mismatch');
27
- }
28
- }
29
- /** Native convention: workspace guidance is USER context, never developer/system. */
30
- export function workspaceInstructionInputs(snapshot, targetPath) {
31
- verifyWorkspaceInstructionSnapshot(snapshot);
32
- return instructionsForWorkspacePath(snapshot, targetPath).map(file => ({
33
- type: 'text',
34
- text: `# AGENTS.md instructions for ${dirname(file.path)}\n\n<INSTRUCTIONS>\n${file.content}\n</INSTRUCTIONS>`,
35
- }));
36
- }
37
- export function materializeWorkspaceInstructions(snapshot, directory) {
38
- verifyWorkspaceInstructionSnapshot(snapshot);
39
- mkdirSync(directory, { mode: 0o700 });
40
- const root = realpathSync(directory);
41
- const files = [];
42
- for (const file of snapshot.files) {
43
- const target = join(root, file.path);
44
- mkdirSync(dirname(target), { recursive: true, mode: 0o700 });
45
- writeFileSync(target, file.content, { encoding: 'utf8', flag: 'wx', mode: 0o400 });
46
- files.push(target);
47
- }
48
- return Object.freeze({ root, files: Object.freeze(files), snapshotDigest: snapshot.digest });
49
- }
50
- /** Global/home instructions remain excluded, including aliases into readable scratch. */
51
- export function assertNoRuntimeInstructionAliases(stateDirectory) {
52
- try {
53
- const configDirectory = lstatSync(join(stateDirectory, '.codex'));
54
- if (!configDirectory.isDirectory() || configDirectory.isSymbolicLink())
55
- throw new Error('Runtime config directory alias is forbidden');
56
- }
57
- catch (error) {
58
- if (error.code !== 'ENOENT')
59
- throw error;
60
- }
61
- for (const prefix of ['', '.codex/']) {
62
- for (const name of ['AGENTS.md', 'AGENTS.override.md', 'config.toml', 'auth.json']) {
63
- try {
64
- const stat = lstatSync(join(stateDirectory, prefix + name));
65
- if (!stat.isFile() || stat.nlink !== 1)
66
- throw new Error('Runtime instruction/config alias is forbidden');
67
- }
68
- catch (error) {
69
- if (error.code !== 'ENOENT')
70
- throw error;
71
- }
72
- }
73
- }
74
- }