aegiscode 7.0.6 → 7.0.7
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.7",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
package/src/app.js
CHANGED
|
@@ -158,7 +158,7 @@ function createApp(options = {}) {
|
|
|
158
158
|
let provisionAttempted = false;
|
|
159
159
|
let keyFailure = '';
|
|
160
160
|
async function provisionDeviceKey() {
|
|
161
|
-
const result = await autoProvisionApiKey(client, credentials);
|
|
161
|
+
const result = await autoProvisionApiKey(client, credentials, { app: 'cli' });
|
|
162
162
|
keyFailure = result.key ? '' : provisionFailureText(result);
|
|
163
163
|
return result;
|
|
164
164
|
}
|
|
@@ -171,8 +171,9 @@ function createApp(options = {}) {
|
|
|
171
171
|
render.renderNotice(
|
|
172
172
|
ctx(),
|
|
173
173
|
'info',
|
|
174
|
-
`
|
|
174
|
+
`auto-provisioned a free account` +
|
|
175
175
|
(result.ok ? ` (saved to ${credentials.credentialsPath()})` : ' (could not save it — reconfigure with /key)') +
|
|
176
|
+
(result.trialGranted === false ? '. The welcome trial was withheld this hour (too many new devices from this network)' : '') +
|
|
176
177
|
`. Fund it at ${client.promptUrl('topup', 'device_autoprovision')} or run /byok to use your own key.`
|
|
177
178
|
)
|
|
178
179
|
);
|
|
@@ -1692,11 +1693,12 @@ function createApp(options = {}) {
|
|
|
1692
1693
|
// always goes to `err` regardless of `json`.
|
|
1693
1694
|
if (!client.apiKey && !provisionAttempted) {
|
|
1694
1695
|
provisionAttempted = true;
|
|
1695
|
-
const result = await autoProvisionApiKey(client, credentials);
|
|
1696
|
+
const result = await autoProvisionApiKey(client, credentials, { app: 'cli' });
|
|
1696
1697
|
if (result.key) {
|
|
1697
1698
|
err.write(
|
|
1698
|
-
`aegiscode:
|
|
1699
|
+
`aegiscode: auto-provisioned a free account` +
|
|
1699
1700
|
(result.ok ? ` (saved to ${credentials.credentialsPath()})` : ' (could not save it — reconfigure with /key)') +
|
|
1701
|
+
(result.trialGranted === false ? '. The welcome trial was withheld this hour (too many new devices from this network)' : '') +
|
|
1700
1702
|
`. Fund it at ${client.promptUrl('topup', 'device_autoprovision')} or run /byok to use your own key.\n`
|
|
1701
1703
|
);
|
|
1702
1704
|
}
|
package/src/topup.js
CHANGED
|
@@ -68,7 +68,7 @@ async function ensureKey(client, store) {
|
|
|
68
68
|
const mod = loadShared('client/auto-provision.js');
|
|
69
69
|
const provision = mod.autoProvisionApiKey || mod.default;
|
|
70
70
|
if (typeof provision === 'function') {
|
|
71
|
-
const res = await provision(client, store);
|
|
71
|
+
const res = await provision(client, store, { app: 'cli' });
|
|
72
72
|
if (res && res.key && typeof client.setApiKey === 'function') client.setApiKey(res.key);
|
|
73
73
|
}
|
|
74
74
|
} catch {
|
package/vendor/client/aegis.js
CHANGED
|
@@ -855,10 +855,11 @@ function createClient(opts = {}) {
|
|
|
855
855
|
* zero balance. Re-registering an already-known fingerprint does NOT
|
|
856
856
|
* re-grant it; the pool balance gate still applies once the allowance is
|
|
857
857
|
* spent or the 30 days lapse. Sends no API key of its own — there isn't
|
|
858
|
-
* one yet.
|
|
858
|
+
* one yet. `opts.app` names the host ('cli' | 'desktop' | 'mcp') so the
|
|
859
|
+
* server files this machine under its real name, not 'other'.
|
|
859
860
|
*/
|
|
860
861
|
async function registerDevice(fingerprint, opts) {
|
|
861
|
-
return apiPost('/api/v1/auth/register-device', { fingerprint }, undefined, opts);
|
|
862
|
+
return apiPost('/api/v1/auth/register-device', { fingerprint, app: opts && opts.app }, undefined, opts);
|
|
862
863
|
}
|
|
863
864
|
|
|
864
865
|
/** Build the OpenAI-style messages array from either a full history or the
|
|
@@ -48,6 +48,7 @@ function provisionFailureText(result) {
|
|
|
48
48
|
const err = result && result.error;
|
|
49
49
|
if (!err) return 'the server returned no account key';
|
|
50
50
|
if (err.status === 429) return 'too many sign-ups from this network — try again later';
|
|
51
|
+
if (err.status >= 500) return `aegiscloud.org failed to register this device: ${err.message}`;
|
|
51
52
|
if (isTransientRegisterError(err)) return 'could not reach aegiscloud.org';
|
|
52
53
|
return `the server refused the request (HTTP ${err.status})`;
|
|
53
54
|
}
|
|
@@ -55,27 +56,34 @@ function provisionFailureText(result) {
|
|
|
55
56
|
/**
|
|
56
57
|
* @param {object} aegisClient A client from client/aegis.js (createClient()).
|
|
57
58
|
* @param {object} credentials client/credentials.js (or a compatible double).
|
|
58
|
-
* @param {number[]} [
|
|
59
|
-
*
|
|
59
|
+
* @param {{app?: string, retryDelaysMs?: number[]}} [options] `app` names the host
|
|
60
|
+
* for the server's presence panel; `retryDelaysMs` waits before each retry of a
|
|
61
|
+
* transient failure.
|
|
62
|
+
* @returns {Promise<{ok: boolean, key: string, trialGranted?: boolean, error?: Error}>}
|
|
60
63
|
* `ok` is true only when a usable key was obtained AND persisted to the
|
|
61
64
|
* shared store; `aegisClient.setApiKey()` has already been called on
|
|
62
65
|
* success, so the caller's client is immediately usable either way it
|
|
63
|
-
* inspects `ok`.
|
|
66
|
+
* inspects `ok`. `trialGranted` is false when the server withheld the
|
|
67
|
+
* welcome trial (the account and key are still valid).
|
|
64
68
|
*/
|
|
65
|
-
async function autoProvisionApiKey(aegisClient, credentials,
|
|
69
|
+
async function autoProvisionApiKey(aegisClient, credentials, options = {}) {
|
|
70
|
+
if (Array.isArray(options)) {
|
|
71
|
+
throw new TypeError('autoProvisionApiKey takes { app, retryDelaysMs }; a bare retry array is no longer accepted');
|
|
72
|
+
}
|
|
66
73
|
if (aegisClient.apiKey) return { ok: true, key: aegisClient.apiKey };
|
|
74
|
+
const { app, retryDelaysMs = DEVICE_REGISTER_RETRY_DELAYS_MS } = options;
|
|
67
75
|
let lastError = null;
|
|
68
76
|
for (let attempt = 0; attempt <= retryDelaysMs.length; attempt++) {
|
|
69
77
|
if (attempt > 0) await new Promise((resolve) => setTimeout(resolve, retryDelaysMs[attempt - 1]));
|
|
70
78
|
const controller = new AbortController();
|
|
71
79
|
const timer = setTimeout(() => controller.abort(), DEVICE_REGISTER_TIMEOUT_MS);
|
|
72
80
|
try {
|
|
73
|
-
const data = await aegisClient.registerDevice(machineFingerprint(), { signal: controller.signal });
|
|
81
|
+
const data = await aegisClient.registerDevice(machineFingerprint(), { app, signal: controller.signal });
|
|
74
82
|
const key = data && typeof data.api_key === 'string' ? data.api_key.trim() : '';
|
|
75
83
|
if (!key) return { ok: false, key: '' };
|
|
76
84
|
const saved = credentials.saveApiKey(key);
|
|
77
85
|
aegisClient.setApiKey(key);
|
|
78
|
-
return { ok: !!saved.ok, key };
|
|
86
|
+
return { ok: !!saved.ok, key, trialGranted: data.trial_granted };
|
|
79
87
|
} catch (err) {
|
|
80
88
|
lastError = err;
|
|
81
89
|
if (!isTransientRegisterError(err)) break;
|
|
@@ -111,8 +111,7 @@ function persistedInstallId() {
|
|
|
111
111
|
* 4. `hostname:platform:arch` — last resort, kept only so this never throws.
|
|
112
112
|
*
|
|
113
113
|
* Only step 4 is guessable by a third party; steps 2 and 3 are both per-host
|
|
114
|
-
* unique.
|
|
115
|
-
* abuse review can tell a genuine re-registration from a forged one.
|
|
114
|
+
* unique.
|
|
116
115
|
*
|
|
117
116
|
* @param {string} [overrideId] - test-only override for the raw machine identity.
|
|
118
117
|
*/
|
|
@@ -136,15 +135,9 @@ function machineIdentity(overrideId) {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
/** Which identity class the fingerprint on THIS host is derived from. */
|
|
140
|
-
function machineIdentityKind() {
|
|
141
|
-
return machineIdentity().kind;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
138
|
module.exports = {
|
|
145
139
|
machineFingerprint,
|
|
146
140
|
machineIdentity,
|
|
147
|
-
machineIdentityKind,
|
|
148
141
|
readMachineId,
|
|
149
142
|
persistedInstallId,
|
|
150
143
|
};
|
package/vendor/mcp/server.js
CHANGED
|
@@ -83,7 +83,7 @@ let provisionAttempted = false;
|
|
|
83
83
|
async function ensureApiKey() {
|
|
84
84
|
if (aegis.apiKey || provisionAttempted) return;
|
|
85
85
|
provisionAttempted = true;
|
|
86
|
-
const result = await autoProvisionApiKey(aegis, credentials);
|
|
86
|
+
const result = await autoProvisionApiKey(aegis, credentials, { app: 'mcp' });
|
|
87
87
|
if (result.error) {
|
|
88
88
|
process.stderr.write(`aegis: device auto-registration failed (${result.error.message}) — falling back to manual setup.\n`);
|
|
89
89
|
return;
|