mindvest-atlas 0.6.2 → 0.6.3
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 +1 -1
- package/src/commands/remote-control.js +5 -0
- package/src/config.js +1 -1
- package/src/remote-control.js +64 -0
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import { color, eprintln } from '../util/ui.js';
|
|
|
17
17
|
import {
|
|
18
18
|
DEFAULT_TIMEOUT_MS, claimRun, computerName, jobEnv, listJobFiles, listRuns, machineId,
|
|
19
19
|
osLabel, readJobFile, releaseRun, staleness, summarize, tail, workspace, workspaceRoot,
|
|
20
|
+
writeHelpers,
|
|
20
21
|
} from '../remote-control.js';
|
|
21
22
|
import fs from 'node:fs';
|
|
22
23
|
import path from 'node:path';
|
|
@@ -128,6 +129,10 @@ async function runJob(job, root, timeoutMs) {
|
|
|
128
129
|
return undefined;
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
// Refreshed every run, so a job always has the supported way to reach a
|
|
133
|
+
// secret and never a reason to open .env itself.
|
|
134
|
+
writeHelpers(dir);
|
|
135
|
+
|
|
131
136
|
eprintln(color.dim(`▶ ${name}`));
|
|
132
137
|
const env = {
|
|
133
138
|
...process.env,
|
package/src/config.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
|
|
5
|
-
export const VERSION = '0.6.
|
|
5
|
+
export const VERSION = '0.6.3';
|
|
6
6
|
export const DEFAULT_BASE_URL = 'https://atlasmcp.finmanagerai.com';
|
|
7
7
|
export const DEFAULT_SCOPE = 'atlas broker';
|
|
8
8
|
export const CLIENT_NAME = 'Atlas CLI';
|
package/src/remote-control.js
CHANGED
|
@@ -168,6 +168,70 @@ export function readEnvFile(file) {
|
|
|
168
168
|
* Shared first so a key is typed once; the job's own last so a job that wants
|
|
169
169
|
* its own value gets it. Neither is required.
|
|
170
170
|
*/
|
|
171
|
+
/**
|
|
172
|
+
* Written into every job folder before it runs, in both languages.
|
|
173
|
+
*
|
|
174
|
+
* The job imports this instead of opening .env — so the script the model writes
|
|
175
|
+
* has no reason to touch the file, and a model debugging that script has nothing
|
|
176
|
+
* to learn by trying. Regenerated on every run, so editing or deleting it
|
|
177
|
+
* changes nothing.
|
|
178
|
+
*/
|
|
179
|
+
export function writeHelpers(dir) {
|
|
180
|
+
const py = `"""Secrets for this job. Written by Atlas — edits are overwritten.
|
|
181
|
+
|
|
182
|
+
Values come from the environment Atlas set up before starting this script. Do
|
|
183
|
+
NOT open .env: this module is the supported way to reach a secret, and the file
|
|
184
|
+
itself is not something a script or a model needs to read.
|
|
185
|
+
"""
|
|
186
|
+
import os
|
|
187
|
+
import sys
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def secret(name, default=None):
|
|
191
|
+
"""The value of one secret, for USE — never for printing or logging."""
|
|
192
|
+
return os.environ.get(name, default)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def has_secret(name):
|
|
196
|
+
"""Whether a secret has been filled in. True/False only, never the value."""
|
|
197
|
+
return bool(os.environ.get(name))
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def require(*names):
|
|
201
|
+
"""Stop cleanly when a secret has not been filled in yet."""
|
|
202
|
+
missing = [n for n in names if not os.environ.get(n)]
|
|
203
|
+
if missing:
|
|
204
|
+
print("Missing: %s. Add the value in Atlas Remote Control, then run again."
|
|
205
|
+
% ", ".join(missing))
|
|
206
|
+
sys.exit(2)
|
|
207
|
+
`;
|
|
208
|
+
const js = `// Secrets for this job. Written by Atlas — edits are overwritten.
|
|
209
|
+
//
|
|
210
|
+
// Values come from the environment Atlas set up before starting this script. Do
|
|
211
|
+
// NOT open .env: this module is the supported way to reach a secret, and the
|
|
212
|
+
// file itself is not something a script or a model needs to read.
|
|
213
|
+
|
|
214
|
+
/** The value of one secret, for USE — never for printing or logging. */
|
|
215
|
+
export const secret = (name, fallback) => process.env[name] ?? fallback;
|
|
216
|
+
|
|
217
|
+
/** Whether a secret has been filled in. True/false only, never the value. */
|
|
218
|
+
export const hasSecret = (name) => Boolean(process.env[name]);
|
|
219
|
+
|
|
220
|
+
/** Stop cleanly when a secret has not been filled in yet. */
|
|
221
|
+
export function require_(...names) {
|
|
222
|
+
const missing = names.filter((n) => !process.env[n]);
|
|
223
|
+
if (missing.length) {
|
|
224
|
+
console.log(\`Missing: \${missing.join(", ")}. Add the value in Atlas Remote Control, then run again.\`);
|
|
225
|
+
process.exit(2);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
`;
|
|
229
|
+
try {
|
|
230
|
+
fs.writeFileSync(path.join(dir, 'atlas_env.py'), py);
|
|
231
|
+
fs.writeFileSync(path.join(dir, 'atlas_env.js'), js);
|
|
232
|
+
} catch { /* a helper is a courtesy, never a failure */ }
|
|
233
|
+
}
|
|
234
|
+
|
|
171
235
|
export function jobEnv(dir, root) {
|
|
172
236
|
return { ...readEnvFile(path.join(workspaceRoot(root), '.env')), ...readEnvFile(path.join(dir, '.env')) };
|
|
173
237
|
}
|