cicy-code 2.3.327 → 2.3.329

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 (2) hide show
  1. package/bin/cicy-code.js +34 -11
  2. package/package.json +5 -5
package/bin/cicy-code.js CHANGED
@@ -21,7 +21,7 @@ const os = require('os');
21
21
  const path = require('path');
22
22
 
23
23
  const rawArgs = process.argv.slice(2);
24
- const { email: cloudEmail, args } = takeEmailArg(rawArgs);
24
+ const { email: cloudEmail, team: cloudTeam, args } = takeCloudArgs(rawArgs);
25
25
  const PORT = process.env.PORT || '8008';
26
26
  const CLOUD_ORIGIN = (process.env.CICY_CLOUD_ORIGIN || 'https://cicy-ai.com').replace(/\/$/, '');
27
27
 
@@ -56,7 +56,7 @@ main().catch((err) => {
56
56
 
57
57
  async function main() {
58
58
  let cloudEnv = {};
59
- if (cloudEmail) cloudEnv = await cloudLogin(cloudEmail);
59
+ if (cloudEmail) cloudEnv = await cloudLogin(cloudEmail, cloudTeam);
60
60
  if (!isUtility) ensurePortFree(PORT);
61
61
  const child = spawn(binPath, args, {
62
62
  stdio: 'inherit',
@@ -68,9 +68,10 @@ async function main() {
68
68
  });
69
69
  }
70
70
 
71
- function takeEmailArg(input) {
71
+ function takeCloudArgs(input) {
72
72
  const output = [];
73
73
  let email = '';
74
+ let team = '';
74
75
  for (let i = 0; i < input.length; i += 1) {
75
76
  const value = input[i];
76
77
  if (value === '--email') {
@@ -78,6 +79,11 @@ function takeEmailArg(input) {
78
79
  i += 1;
79
80
  } else if (value.startsWith('--email=')) {
80
81
  email = value.slice('--email='.length).trim().toLowerCase();
82
+ } else if (value === '--team') {
83
+ team = String(input[i + 1] || '').trim();
84
+ i += 1;
85
+ } else if (value.startsWith('--team=')) {
86
+ team = value.slice('--team='.length).trim();
81
87
  } else {
82
88
  output.push(value);
83
89
  }
@@ -85,21 +91,34 @@ function takeEmailArg(input) {
85
91
  if (email && !/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) {
86
92
  throw new Error('invalid --email address');
87
93
  }
88
- return { email, args: output };
94
+ if (team && !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/.test(team)) {
95
+ throw new Error('invalid --team identifier');
96
+ }
97
+ return { email, team, args: output };
89
98
  }
90
99
 
91
- async function cloudLogin(email) {
100
+ async function cloudLogin(email, requestedTeam) {
92
101
  const credentialPath = cloudCredentialPath();
93
102
  const saved = readJSON(credentialPath);
94
103
  const instanceId = String(saved.instance_id || '').trim() ||
95
104
  `code-${crypto.randomBytes(18).toString('hex')}`;
105
+ const teamId = requestedTeam || String(saved.team_id || '').trim() || `team-${Date.now()}`;
96
106
  let token = saved.email === email ? String(saved.token || '') : '';
97
107
 
98
108
  if (token) {
99
109
  try {
100
- await registerCloudInstance(token, instanceId);
110
+ await registerCloudInstance(token, instanceId, teamId);
111
+ writeCredential(credentialPath, {
112
+ ...saved,
113
+ email,
114
+ instance_id: instanceId,
115
+ team_id: teamId,
116
+ token,
117
+ cloud_origin: CLOUD_ORIGIN,
118
+ updated_at: new Date().toISOString(),
119
+ });
101
120
  console.log(`cicy-code: CiCy Cloud connected as ${email}`);
102
- return cloudEnvironment(email, instanceId, token);
121
+ return cloudEnvironment(email, instanceId, teamId, token);
103
122
  } catch {
104
123
  token = '';
105
124
  }
@@ -114,6 +133,7 @@ async function cloudLogin(email) {
114
133
  flow: 'desktop_poll',
115
134
  lang: preferredLanguage(),
116
135
  ...loginRequestInfo(instanceId),
136
+ teamId,
117
137
  },
118
138
  });
119
139
  console.log(`cicy-code: login email sent to ${email}`);
@@ -128,16 +148,17 @@ async function cloudLogin(email) {
128
148
  throw new Error('email login expired; start cicy-code again');
129
149
  }
130
150
  token = String(result.token);
131
- await registerCloudInstance(token, instanceId);
151
+ await registerCloudInstance(token, instanceId, teamId);
132
152
  writeCredential(credentialPath, {
133
153
  email,
134
154
  instance_id: instanceId,
155
+ team_id: teamId,
135
156
  token,
136
157
  cloud_origin: CLOUD_ORIGIN,
137
158
  updated_at: new Date().toISOString(),
138
159
  });
139
160
  console.log(`cicy-code: login successful; this device is now bound to ${email}`);
140
- return cloudEnvironment(email, instanceId, token);
161
+ return cloudEnvironment(email, instanceId, teamId, token);
141
162
  }
142
163
  throw new Error('email login timed out; start cicy-code again');
143
164
  }
@@ -171,12 +192,13 @@ function loginRequestInfo(instanceId) {
171
192
  };
172
193
  }
173
194
 
174
- async function registerCloudInstance(token, instanceId) {
195
+ async function registerCloudInstance(token, instanceId, teamId) {
175
196
  await requestJSON('/api/code/instances/register', {
176
197
  method: 'POST',
177
198
  token,
178
199
  body: {
179
200
  instanceId,
201
+ teamId,
180
202
  platform: isColab() ? 'colab' : process.platform,
181
203
  arch: process.arch,
182
204
  runtime: isColab() ? 'colab' : 'native',
@@ -185,11 +207,12 @@ async function registerCloudInstance(token, instanceId) {
185
207
  });
186
208
  }
187
209
 
188
- function cloudEnvironment(email, instanceId, token) {
210
+ function cloudEnvironment(email, instanceId, teamId, token) {
189
211
  return {
190
212
  CICY_CLOUD_ORIGIN: CLOUD_ORIGIN,
191
213
  CICY_CLOUD_EMAIL: email,
192
214
  CICY_CLOUD_INSTANCE_ID: instanceId,
215
+ CICY_CLOUD_TEAM_ID: teamId,
193
216
  CICY_CLOUD_TOKEN: token,
194
217
  };
195
218
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.3.327",
6
+ "version": "2.3.329",
7
7
  "description": "CiCy Code - AI-powered development environment",
8
8
  "author": {
9
9
  "name": "cicybot",
@@ -16,10 +16,10 @@
16
16
  "bin/cicy-code.js"
17
17
  ],
18
18
  "optionalDependencies": {
19
- "cicy-code-darwin-arm64": "2.3.327",
20
- "cicy-code-darwin-x64": "2.3.327",
21
- "cicy-code-linux-arm64": "2.3.327",
22
- "cicy-code-linux-x64": "2.3.327"
19
+ "cicy-code-darwin-arm64": "2.3.329",
20
+ "cicy-code-darwin-x64": "2.3.329",
21
+ "cicy-code-linux-arm64": "2.3.329",
22
+ "cicy-code-linux-x64": "2.3.329"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",