thinkncollab-shell 0.0.20 → 2.0.0-beta.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 (201) hide show
  1. package/LICENSE +82 -0
  2. package/Readme.md +246 -502
  3. package/dist/bin/thinknsh.js +8 -0
  4. package/dist/src/commands/auth/login.js +7 -0
  5. package/dist/src/commands/auth/logout.js +7 -0
  6. package/dist/src/commands/auth/register.js +7 -0
  7. package/dist/src/commands/auth/whoami.js +7 -0
  8. package/dist/src/commands/dock/bench.js +7 -0
  9. package/dist/src/commands/dock/ci.js +7 -0
  10. package/dist/src/commands/dock/cluster.js +7 -0
  11. package/dist/src/commands/dock/containers.js +7 -0
  12. package/dist/src/commands/dock/dock.js +7 -0
  13. package/dist/src/commands/github/commits.js +7 -0
  14. package/dist/src/commands/github/issue-create.js +7 -0
  15. package/dist/src/commands/github/issues.js +7 -0
  16. package/dist/src/commands/github/pulls.js +7 -0
  17. package/dist/src/commands/github/statusgh.js +7 -0
  18. package/dist/src/commands/index.js +7 -0
  19. package/dist/src/commands/message/say.js +7 -0
  20. package/dist/src/commands/room/join.js +7 -0
  21. package/dist/src/commands/room/leave.js +7 -0
  22. package/dist/src/commands/room/rooms.js +7 -0
  23. package/dist/src/commands/room/sync.js +7 -0
  24. package/dist/src/commands/sandbox/console.js +7 -0
  25. package/dist/src/commands/sandbox/dep.js +7 -0
  26. package/dist/src/commands/sandbox/deploy.js +7 -0
  27. package/dist/src/commands/sandbox/dev.js +7 -0
  28. package/dist/src/commands/sandbox/exec.js +7 -0
  29. package/dist/src/commands/sandbox/freeze.js +7 -0
  30. package/dist/src/commands/sandbox/push.js +7 -0
  31. package/dist/src/commands/sandbox/resume.js +7 -0
  32. package/dist/src/commands/sandbox/sandbox.js +7 -0
  33. package/dist/src/commands/sandbox/share.js +7 -0
  34. package/dist/src/commands/sandbox/snapshot.js +7 -0
  35. package/dist/src/commands/sandbox/sync-deps.js +7 -0
  36. package/dist/src/commands/shell/doctor.js +7 -0
  37. package/dist/src/commands/shell/notifications.js +7 -0
  38. package/dist/src/commands/shell/notify.js +7 -0
  39. package/dist/src/commands/shell/status.js +7 -0
  40. package/dist/src/commands/shell/version.js +7 -0
  41. package/dist/src/commands/tasks/build.js +7 -0
  42. package/dist/src/commands/tasks/complete.js +7 -0
  43. package/dist/src/commands/tasks/create-task.js +7 -0
  44. package/dist/src/commands/tasks/loadtest.js +7 -0
  45. package/dist/src/commands/tasks/task-status.js +7 -0
  46. package/dist/src/commands/tasks/task.js +7 -0
  47. package/dist/src/commands/tasks/tasks.js +7 -0
  48. package/dist/src/commands/team/invite.js +7 -0
  49. package/dist/src/commands/team/myteam.js +7 -0
  50. package/dist/src/commands/team/teammates.js +7 -0
  51. package/dist/src/commands/terminal/share.js +7 -0
  52. package/dist/src/core/api-client.js +7 -0
  53. package/dist/src/core/crypto/e2ee-vault.js +7 -0
  54. package/dist/src/core/dep-store.js +7 -0
  55. package/dist/src/core/dependency-tracker.js +7 -0
  56. package/dist/src/core/geekload.js +7 -0
  57. package/dist/src/core/local-runner.js +7 -0
  58. package/dist/src/core/multi-lang-scanner.js +7 -0
  59. package/dist/src/core/notification-window.js +8 -0
  60. package/dist/src/core/notify-auth.js +7 -0
  61. package/dist/src/core/project-config.js +7 -0
  62. package/dist/src/core/sandbox/arch-shim.js +7 -0
  63. package/dist/src/core/sandbox/capsule-builder.js +7 -0
  64. package/dist/src/core/sandbox/cgroups.js +7 -0
  65. package/dist/src/core/sandbox/container-monitor.js +7 -0
  66. package/dist/src/core/sandbox/crun-manager.js +7 -0
  67. package/dist/src/core/sandbox/engine.js +7 -0
  68. package/dist/src/core/sandbox/image-manager.js +7 -0
  69. package/dist/src/core/sandbox/image-store.js +7 -0
  70. package/dist/src/core/sandbox/index.js +7 -0
  71. package/dist/src/core/sandbox/macos-sandbox.js +7 -0
  72. package/dist/src/core/sandbox/microvm-manager.js +7 -0
  73. package/dist/src/core/sandbox/native-service-manager.js +7 -0
  74. package/dist/src/core/sandbox/network.js +7 -0
  75. package/dist/src/core/sandbox/oci-exporter.js +7 -0
  76. package/dist/src/core/sandbox/oci-puller.js +7 -0
  77. package/dist/src/core/sandbox/oci-runtime-spec.js +7 -0
  78. package/dist/src/core/sandbox/policy-engine.js +7 -0
  79. package/dist/src/core/sandbox/port-proxy-daemon.js +7 -0
  80. package/dist/src/core/sandbox/room-sync-manager.js +7 -0
  81. package/dist/src/core/sandbox/runtime-manager.js +7 -0
  82. package/dist/src/core/sandbox/snapshot-manager.js +7 -0
  83. package/dist/src/core/sandbox/storage.js +7 -0
  84. package/dist/src/core/sandbox/supervisor.js +7 -0
  85. package/dist/src/core/sandbox/tunnel-daemon.js +7 -0
  86. package/dist/src/core/sandbox/tunnel.js +7 -0
  87. package/dist/src/core/sandbox/window-launcher.js +7 -0
  88. package/dist/src/core/sandbox/windows-wsl2.js +7 -0
  89. package/dist/src/core/sandbox-window.js +8 -0
  90. package/dist/src/core/shell.js +7 -0
  91. package/dist/src/core/websocket.js +7 -0
  92. package/dist/src/dock/api/routes.js +7 -0
  93. package/dist/src/dock/api/server.js +7 -0
  94. package/dist/src/dock/api/wire.js +7 -0
  95. package/dist/src/dock/bench/memory.js +7 -0
  96. package/dist/src/dock/bench/runner.js +7 -0
  97. package/dist/src/dock/build/builder.js +7 -0
  98. package/dist/src/dock/build/buildfile.js +7 -0
  99. package/dist/src/dock/build/buildkit.js +7 -0
  100. package/dist/src/dock/build/changes.js +7 -0
  101. package/dist/src/dock/ci/actions.js +7 -0
  102. package/dist/src/dock/ci/runner.js +7 -0
  103. package/dist/src/dock/ci/workflow.js +7 -0
  104. package/dist/src/dock/cli/api.js +7 -0
  105. package/dist/src/dock/cli/args.js +7 -0
  106. package/dist/src/dock/cli/commands.js +7 -0
  107. package/dist/src/dock/cli/compose.js +7 -0
  108. package/dist/src/dock/cli/context.js +7 -0
  109. package/dist/src/dock/cli/files.js +7 -0
  110. package/dist/src/dock/cli/format.js +7 -0
  111. package/dist/src/dock/cli/manage.js +7 -0
  112. package/dist/src/dock/cli/moved.js +7 -0
  113. package/dist/src/dock/cli/services.js +7 -0
  114. package/dist/src/dock/cli/session.js +7 -0
  115. package/dist/src/dock/cli/workspace.js +7 -0
  116. package/dist/src/dock/client.js +7 -0
  117. package/dist/src/dock/compat/cases.js +7 -0
  118. package/dist/src/dock/compat/runner.js +7 -0
  119. package/dist/src/dock/config.js +7 -0
  120. package/dist/src/dock/daemon-main.js +7 -0
  121. package/dist/src/dock/daemon.js +7 -0
  122. package/dist/src/dock/deploy/compose.js +7 -0
  123. package/dist/src/dock/engine.js +7 -0
  124. package/dist/src/dock/image/archive.js +7 -0
  125. package/dist/src/dock/image/auth.js +7 -0
  126. package/dist/src/dock/image/reference.js +7 -0
  127. package/dist/src/dock/image/registry.js +7 -0
  128. package/dist/src/dock/image/tar.js +7 -0
  129. package/dist/src/dock/index.js +7 -0
  130. package/dist/src/dock/linux/host.js +7 -0
  131. package/dist/src/dock/paths.js +7 -0
  132. package/dist/src/dock/runtime/emulation.js +7 -0
  133. package/dist/src/dock/runtime/fsevents.js +7 -0
  134. package/dist/src/dock/runtime/fsops.js +7 -0
  135. package/dist/src/dock/runtime/hostfwd.js +7 -0
  136. package/dist/src/dock/runtime/logs.js +7 -0
  137. package/dist/src/dock/runtime/network.js +7 -0
  138. package/dist/src/dock/runtime/ports.js +7 -0
  139. package/dist/src/dock/runtime/rootfs.js +7 -0
  140. package/dist/src/dock/runtime/seccomp-profile.LICENSE +202 -0
  141. package/dist/src/dock/runtime/seccomp-profile.json +1227 -0
  142. package/dist/src/dock/runtime/seccomp.js +7 -0
  143. package/dist/src/dock/runtime/spec.js +7 -0
  144. package/dist/src/dock/runtime/stats.js +7 -0
  145. package/dist/src/dock/runtime/volumes.js +7 -0
  146. package/dist/src/dock/selftest.js +7 -0
  147. package/dist/src/dock/setup/app.js +7 -0
  148. package/dist/src/dock/setup/autostart.js +7 -0
  149. package/dist/src/dock/setup/index.js +7 -0
  150. package/dist/src/dock/setup/integrate.js +7 -0
  151. package/dist/src/dock/setup/migrate.js +7 -0
  152. package/dist/src/dock/state/store.js +7 -0
  153. package/dist/src/dock/ui/page.js +385 -0
  154. package/dist/src/dock/ui/server.js +7 -0
  155. package/dist/src/dock/version.js +7 -0
  156. package/dist/src/dock/workspace/apps.js +7 -0
  157. package/dist/src/dock/workspace/workspace.js +7 -0
  158. package/dist/src/events/notifications.js +7 -0
  159. package/dist/src/utils/logger.js +7 -0
  160. package/dist/src/utils/terminalCrypto.js +7 -0
  161. package/package.json +41 -16
  162. package/bin/thinknsh.js +0 -71
  163. package/src/commands/auth/login.js +0 -84
  164. package/src/commands/auth/logout.js +0 -32
  165. package/src/commands/auth/register.js +0 -52
  166. package/src/commands/auth/whoami.js +0 -52
  167. package/src/commands/github/commits.js +0 -58
  168. package/src/commands/github/issue-create.js +0 -59
  169. package/src/commands/github/issues.js +0 -57
  170. package/src/commands/github/pulls.js +0 -58
  171. package/src/commands/github/statusgh.js +0 -50
  172. package/src/commands/index.js +0 -136
  173. package/src/commands/message/say.js +0 -49
  174. package/src/commands/room/join.js +0 -142
  175. package/src/commands/room/leave.js +0 -24
  176. package/src/commands/room/rooms.js +0 -66
  177. package/src/commands/shell/notify.js +0 -88
  178. package/src/commands/shell/status.js +0 -73
  179. package/src/commands/shell/version.js +0 -18
  180. package/src/commands/tasks/build.js +0 -190
  181. package/src/commands/tasks/complete.js +0 -940
  182. package/src/commands/tasks/create-task.js +0 -101
  183. package/src/commands/tasks/loadtest.js +0 -101
  184. package/src/commands/tasks/suggestTask.js +0 -0
  185. package/src/commands/tasks/task-status.js +0 -72
  186. package/src/commands/tasks/task.js +0 -182
  187. package/src/commands/tasks/tasks.js +0 -184
  188. package/src/commands/team/invite.js +0 -46
  189. package/src/commands/team/myteam.js +0 -78
  190. package/src/commands/team/teammates.js +0 -52
  191. package/src/commands/terminal/share.js +0 -261
  192. package/src/core/api-client.js +0 -246
  193. package/src/core/geekload.js +0 -524
  194. package/src/core/local-runner.js +0 -861
  195. package/src/core/notification-window.js +0 -165
  196. package/src/core/project-config.js +0 -100
  197. package/src/core/shell.js +0 -734
  198. package/src/core/websocket.js +0 -657
  199. package/src/events/notifications.js +0 -184
  200. package/src/utils/logger.js +0 -159
  201. package/src/utils/terminalCrypto.js +0 -47
@@ -1,165 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * ThinkNCollab — Notification Window
4
- * Spawned automatically by the main shell as a separate terminal process.
5
- * Connects to the main shell via TCP and displays live notifications.
6
- */
7
-
8
- const net = require('net');
9
- const chalk = require('chalk');
10
-
11
- const PORT = parseInt(process.env.THINKNSH_NOTIFY_PORT || '7379');
12
- const HOST = '127.0.0.1';
13
-
14
- // ── UI ────────────────────────────────────────────────────────────────────────
15
-
16
- function clearScreen() { process.stdout.write('\x1Bc'); }
17
-
18
- function drawHeader() {
19
- const width = process.stdout.columns || 80;
20
- const title = ' 🔔 ThinkNCollab — Live Notifications ';
21
- const line = '━'.repeat(width);
22
- console.log(chalk.cyan(line));
23
- console.log(chalk.cyan.bold(title.padStart(Math.floor((width + title.length) / 2))));
24
- console.log(chalk.cyan(line));
25
- console.log(chalk.dim(` Port: ${PORT} | Notifications will appear here in real time.`));
26
- console.log(chalk.dim(' Close this window or press Ctrl+C to stop.\n'));
27
- }
28
-
29
- function beep() {
30
- // Terminal bell — works on Windows CMD, macOS Terminal, Linux
31
- process.stdout.write('\x07');
32
- }
33
-
34
- function printNotification(data) {
35
- const timestamp = new Date().toLocaleTimeString();
36
- const ts = chalk.dim(`[${timestamp}]`);
37
-
38
- switch (data.type) {
39
- case 'task':
40
- beep();
41
- console.log(`${ts} 📋 ${chalk.yellow('Task Assigned →')} ${chalk.white(data.message)}`);
42
- break;
43
- case 'task_reopened':
44
- beep();
45
- console.log(`${ts} 🔄 ${chalk.yellow('Task Reopened →')} ${chalk.white(data.message.replace(/^🔄\s*/, ''))}`);
46
- break;
47
- case 'task_completed':
48
- beep();
49
- if (data.message) {
50
- console.log(`${ts} 🎉 ${chalk.green('Task Completed →')} ${chalk.white(data.message.replace(/^🎉\s*/, ''))}`);
51
- } else {
52
- console.log(`${ts} ✅ ${chalk.green(data.userName || 'Someone')} completed ${chalk.white(data.taskTitle)}`);
53
- }
54
- break;
55
- case 'task_progress':
56
- beep();
57
- console.log(`${ts} ⏳ ${chalk.blue('Task Progress →')} ${chalk.white(data.message)}`);
58
- break;
59
- case 'task_assigned':
60
- beep();
61
- console.log(`${ts} 📋 ${chalk.yellow('Task assigned →')} ${chalk.white(data.taskTitle)} ${chalk.dim('by')} ${chalk.cyan(data.assignedBy)}`);
62
- break;
63
- case 'task_started':
64
- console.log(`${ts} ⚡ ${chalk.green(data.userName)} started working on ${chalk.white(data.taskTitle)}`);
65
- break;
66
- case 'message':
67
- beep();
68
- console.log(`${ts} 💬 ${chalk.cyan(data.from)}: ${data.text}`);
69
- break;
70
- case 'userJoined':
71
- console.log(`${ts} 👤 ${chalk.green(data.username)} joined`);
72
- break;
73
- case 'userLeft':
74
- console.log(`${ts} 👤 ${chalk.yellow(data.username)} left`);
75
- break;
76
- case 'connected':
77
- console.log(`${ts} ${chalk.green('✅ Shell connected')}`);
78
- break;
79
- case 'disconnected':
80
- console.log(`${ts} ${chalk.yellow('⚠️ Shell disconnected')}`);
81
- break;
82
- case 'notification': {
83
- beep();
84
- const colors = { success: chalk.green, warning: chalk.yellow, error: chalk.red, info: chalk.blue };
85
- const color = colors[data.level] || chalk.blue;
86
- console.log(`${ts} 📢 ${color(`${data.title}: ${data.message}`)}`);
87
- break;
88
- }
89
- case 'verdict':
90
- beep();
91
- {
92
- const color = data.passed ? chalk.green : chalk.red;
93
- const icon = data.passed ? '✅' : '❌';
94
- const label = data.passed ? 'PASSED' : 'FAILED';
95
- console.log(`${ts} ${icon} ${color(`Build Verdict [${label}]`)}: ${chalk.white(data.reason || '')}`);
96
- }
97
- break;
98
- case 'typing':
99
- beep();
100
- process.stdout.write(`\r${chalk.dim(`✏️ ${data.username} is typing... `)}`);
101
- break;
102
- case 'stoppedTyping':
103
- process.stdout.write('\r' + ' '.repeat(40) + '\r');
104
- break;
105
- default:
106
- if (data.message) {
107
- console.log(`${ts} 📢 ${chalk.white(data.message)}`);
108
- } else {
109
- console.log(`${ts} ${chalk.white(JSON.stringify(data))}`);
110
- }
111
- }
112
- }
113
-
114
- // ── TCP Client ────────────────────────────────────────────────────────────────
115
-
116
- function connect() {
117
- clearScreen();
118
- drawHeader();
119
- console.log(chalk.dim(` Connecting to shell on port ${PORT}...`));
120
-
121
- const client = new net.Socket();
122
- let buffer = '';
123
-
124
- client.connect(PORT, HOST, () => {
125
- console.log(chalk.green(' Connected to shell!\n'));
126
- });
127
-
128
- client.on('data', (chunk) => {
129
- buffer += chunk.toString();
130
- const lines = buffer.split('\n');
131
- buffer = lines.pop();
132
-
133
- lines.forEach(line => {
134
- if (!line.trim()) return;
135
- try {
136
- const data = JSON.parse(line);
137
- printNotification(data);
138
- } catch {
139
- console.log(chalk.dim(line));
140
- }
141
- });
142
- });
143
-
144
- client.on('close', () => {
145
- console.log(chalk.yellow('\n Shell disconnected. Retrying in 3s...'));
146
- setTimeout(connect, 3000);
147
- });
148
-
149
- client.on('error', (err) => {
150
- if (err.code === 'ECONNREFUSED') {
151
- console.log(chalk.dim(` Waiting for shell on port ${PORT}...`));
152
- } else {
153
- console.log(chalk.dim(` Connection error: ${err.message}`));
154
- }
155
- setTimeout(connect, 3000);
156
- });
157
- }
158
-
159
- // ── Ctrl+C ────────────────────────────────────────────────────────────────────
160
- process.on('SIGINT', () => {
161
- console.log(chalk.yellow('\n Notification window closed.'));
162
- process.exit(0);
163
- });
164
-
165
- connect();
@@ -1,100 +0,0 @@
1
- /*
2
- src/core/project-config.js
3
-
4
- Shell-side reader for .tncproject binary files.
5
- NO crypto code — shell only reads the plaintext roomId prefix,
6
- then sends the raw file to the server for decryption.
7
-
8
- File layout (written by server):
9
- [4 bytes] "TNCP" magic
10
- [1 byte] version 0x01
11
- [24 bytes] roomId ASCII hex ← only readable part
12
- [12 bytes] AES-GCM IV ← opaque
13
- [16 bytes] AES-GCM auth tag ← opaque
14
- [N bytes] encrypted payload ← opaque
15
- */
16
-
17
- const fs = require('fs-extra');
18
- const path = require('path');
19
- const os = require('os');
20
-
21
- const CONFIG_FILE = 'tncproject';
22
- const MAGIC = Buffer.from('TNCP');
23
- const ROOM_ID_SIZE = 24;
24
- const MIN_SIZE = 4 + 1 + ROOM_ID_SIZE + 12 + 16 + 2; // 59 bytes minimum
25
-
26
- function findConfigFile(startDir = process.cwd()) {
27
- let dir = path.resolve(startDir);
28
- const root = path.parse(dir).root;
29
-
30
- while (true) {
31
- const candidate = path.join(dir, CONFIG_FILE);
32
- if (fs.existsSync(candidate)) return candidate;
33
- if (dir === root || dir === os.homedir()) break;
34
- dir = path.dirname(dir);
35
- }
36
- return null;
37
- }
38
-
39
- /*
40
- Read and lightly validate a .tncproject file.
41
- Returns { filePath, roomId, fileBase64 } — no decryption.
42
-
43
- @throws if file is missing, wrong format, or roomId looks wrong http://localhost:3001
44
- */
45
- function loadProjectConfig(startDir = process.cwd()) {
46
- const filePath = findConfigFile(startDir);
47
-
48
- if (!filePath) {
49
- throw new Error(
50
- 'No .tncproject file found in this directory or any parent.\n' +
51
- ' Download it from: ThinkNCollab → Room → Project Config'
52
- );
53
- }
54
-
55
- const buf = fs.readFileSync(filePath);
56
-
57
- if (buf.length < MIN_SIZE) {
58
- throw new Error(
59
- 'Invalid .tncproject — file too small or corrupted.\n' +
60
- ' Re-download it from the dashboard.'
61
- );
62
- }
63
-
64
- if (!buf.slice(0, 4).equals(MAGIC)) {
65
- throw new Error(
66
- 'Not a ThinkNCollab project config file.\n' +
67
- ' Re-download from the dashboard.'
68
- );
69
- }
70
-
71
- const version = buf.readUInt8(4);
72
- if (version !== 0x01) {
73
- throw new Error(
74
- `Unsupported .tncproject version (${version}).\n` +
75
- ' Update thinkncollab-shell: npm update -g thinkncollab-shell'
76
- );
77
- }
78
-
79
- // Read roomId from plaintext prefix — bytes 5..28
80
- const roomId = buf.slice(5, 5 + ROOM_ID_SIZE).toString('ascii').trim();
81
-
82
- if (!/^[a-f0-9]{24}$/i.test(roomId)) {
83
- throw new Error(
84
- 'Corrupted .tncproject — invalid roomId.\n' +
85
- ' Re-download it from the dashboard.'
86
- );
87
- }
88
-
89
- return {
90
- filePath,
91
- roomId,
92
- fileBase64: buf.toString('base64'), // sent as-is to server
93
- };
94
- }
95
-
96
- function hasProjectConfig(startDir = process.cwd()) {
97
- return !!findConfigFile(startDir);
98
- }
99
-
100
- module.exports = { loadProjectConfig, hasProjectConfig, CONFIG_FILE };