tines 0.0.160 → 0.0.162
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/dist/index.js +15 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7550,7 +7550,10 @@ function buildSpawnEnv(base, opts) {
|
|
|
7550
7550
|
const env = {
|
|
7551
7551
|
...base,
|
|
7552
7552
|
TINES_API_KEY: opts.apiKey,
|
|
7553
|
-
|
|
7553
|
+
// Own canonicalization at the final child-process boundary too. This
|
|
7554
|
+
// keeps the spawned CLI safe even if a future daemon call site passes
|
|
7555
|
+
// the original --url value instead of its normalized local variable.
|
|
7556
|
+
TINES_API_URL: opts.apiUrl.replace(/\/+$/, "")
|
|
7554
7557
|
};
|
|
7555
7558
|
if (opts.binDir) env.PATH = base.PATH ? `${opts.binDir}${delimiter}${base.PATH}` : opts.binDir;
|
|
7556
7559
|
return env;
|
|
@@ -7826,6 +7829,7 @@ function pidAlive(pid) {
|
|
|
7826
7829
|
}
|
|
7827
7830
|
}
|
|
7828
7831
|
async function runDaemon(opts) {
|
|
7832
|
+
const baseUrl = opts.url.replace(/\/+$/, "");
|
|
7829
7833
|
mkdirSync4(opts.configDir, { recursive: true });
|
|
7830
7834
|
mkdirSync4(workspacesDir(opts.configDir), { recursive: true, mode: 448 });
|
|
7831
7835
|
const sweepKeptWorkspaces = () => {
|
|
@@ -7855,7 +7859,7 @@ async function runDaemon(opts) {
|
|
|
7855
7859
|
);
|
|
7856
7860
|
}
|
|
7857
7861
|
};
|
|
7858
|
-
let creds = loadRunnerCredentials(opts.configDir,
|
|
7862
|
+
let creds = loadRunnerCredentials(opts.configDir, baseUrl, opts.name);
|
|
7859
7863
|
if (creds) {
|
|
7860
7864
|
log(
|
|
7861
7865
|
`reconnecting as runner "${opts.name}" (${creds.runner_id}) \u2014 token from ${opts.configDir}`
|
|
@@ -7863,10 +7867,10 @@ async function runDaemon(opts) {
|
|
|
7863
7867
|
} else {
|
|
7864
7868
|
if (!opts.apiKey) {
|
|
7865
7869
|
throw new Error(
|
|
7866
|
-
`no stored runner token for "${opts.name}" at ${
|
|
7870
|
+
`no stored runner token for "${opts.name}" at ${baseUrl} \u2014 set TINES_API_KEY (a user API key) to register`
|
|
7867
7871
|
);
|
|
7868
7872
|
}
|
|
7869
|
-
const userClient = createApiClient({ baseUrl
|
|
7873
|
+
const userClient = createApiClient({ baseUrl, apiKey: opts.apiKey });
|
|
7870
7874
|
const registered = await userClient.registerRunner({
|
|
7871
7875
|
name: opts.name,
|
|
7872
7876
|
harness: opts.harness,
|
|
@@ -7876,13 +7880,13 @@ async function runDaemon(opts) {
|
|
|
7876
7880
|
platform: `${platform()} ${arch()}`
|
|
7877
7881
|
});
|
|
7878
7882
|
creds = { runner_id: registered.runner.id, token: registered.runner_token };
|
|
7879
|
-
saveRunnerCredentials(opts.configDir,
|
|
7883
|
+
saveRunnerCredentials(opts.configDir, baseUrl, opts.name, creds);
|
|
7880
7884
|
log(`registered runner "${opts.name}" (${creds.runner_id}); token stored in ${opts.configDir}`);
|
|
7881
7885
|
log(
|
|
7882
|
-
`next: route work to "${opts.name}"
|
|
7886
|
+
`next: route work to "${opts.name}" \u2014 ${baseUrl}/agents (or: tines routing set ${opts.name}). Eligible work starts when this runner is available and routing matches. If automation is stopped, resume it in Agents or with tines supervisor enable.`
|
|
7883
7887
|
);
|
|
7884
7888
|
}
|
|
7885
|
-
const client2 = createApiClient({ baseUrl
|
|
7889
|
+
const client2 = createApiClient({ baseUrl, apiKey: creds.token });
|
|
7886
7890
|
const statePath = daemonStatePath(opts.configDir, creds.runner_id);
|
|
7887
7891
|
let shuttingDown = false;
|
|
7888
7892
|
const refresher = new CliRefresher(() => installAgentCli({ configDir: opts.configDir, log }), {
|
|
@@ -8081,7 +8085,7 @@ async function runDaemon(opts) {
|
|
|
8081
8085
|
env: buildSpawnEnv(process.env, {
|
|
8082
8086
|
binDir: cli.binDir,
|
|
8083
8087
|
apiKey: assignment.run_key,
|
|
8084
|
-
apiUrl:
|
|
8088
|
+
apiUrl: baseUrl
|
|
8085
8089
|
}),
|
|
8086
8090
|
stdio: ["ignore", "pipe", "pipe"],
|
|
8087
8091
|
detached: true
|
|
@@ -8191,7 +8195,7 @@ async function runDaemon(opts) {
|
|
|
8191
8195
|
process.on("SIGINT", () => void shutdown());
|
|
8192
8196
|
process.on("SIGTERM", () => void shutdown());
|
|
8193
8197
|
log(
|
|
8194
|
-
`polling ${
|
|
8198
|
+
`polling ${baseUrl} every ${Math.round(opts.pollIntervalMs / 1e3)}s (harness ${opts.harness}, max ${opts.maxConcurrent} concurrent) \u2014 Ctrl-C to stop`
|
|
8195
8199
|
);
|
|
8196
8200
|
let failures = 0;
|
|
8197
8201
|
while (!shuttingDown) {
|
|
@@ -8234,7 +8238,7 @@ async function runDaemon(opts) {
|
|
|
8234
8238
|
});
|
|
8235
8239
|
}
|
|
8236
8240
|
saveDaemonState(statePath, []);
|
|
8237
|
-
clearRunnerCredentials(opts.configDir,
|
|
8241
|
+
clearRunnerCredentials(opts.configDir, baseUrl, opts.name);
|
|
8238
8242
|
throw new Error(
|
|
8239
8243
|
`the supervisor rejected this runner's token (was it rotated?) \u2014 the stored token was dropped; restart with the new token via \`tines runners rotate-token ${opts.name}\` on this machine, or with TINES_API_KEY set to re-register`
|
|
8240
8244
|
);
|
|
@@ -9041,7 +9045,7 @@ function register10(program3) {
|
|
|
9041
9045
|
}
|
|
9042
9046
|
});
|
|
9043
9047
|
withCommon(
|
|
9044
|
-
supervisor.command("enable").description("
|
|
9048
|
+
supervisor.command("enable").description("Resume automation (the kill switch on)")
|
|
9045
9049
|
).action(async (opts) => {
|
|
9046
9050
|
const settings = await client(opts).updateSupervisorSettings({ enabled: true });
|
|
9047
9051
|
if (opts.json) return printJson(settings);
|