agent-transport-system 0.7.27 → 0.7.28
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/ats.js +83 -14
- package/dist/ats.js.map +1 -1
- package/package.json +1 -1
package/dist/ats.js
CHANGED
|
@@ -27,7 +27,7 @@ import wrapAnsi from "wrap-ansi";
|
|
|
27
27
|
import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
|
|
28
28
|
|
|
29
29
|
//#region package.json
|
|
30
|
-
var version = "0.7.
|
|
30
|
+
var version = "0.7.28";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -5459,7 +5459,7 @@ async function getRemoteAuthSessionState(session) {
|
|
|
5459
5459
|
}
|
|
5460
5460
|
function resolveRemoteSessionTimeoutMs(endpoint) {
|
|
5461
5461
|
const url = parseUrlOrNull$3(endpoint);
|
|
5462
|
-
if (url && isLoopbackHostname$
|
|
5462
|
+
if (url && isLoopbackHostname$4(url.hostname)) return LOOPBACK_REMOTE_SESSION_TIMEOUT_MS;
|
|
5463
5463
|
return DEFAULT_REMOTE_SESSION_TIMEOUT_MS;
|
|
5464
5464
|
}
|
|
5465
5465
|
function parseUrlOrNull$3(value) {
|
|
@@ -5469,7 +5469,7 @@ function parseUrlOrNull$3(value) {
|
|
|
5469
5469
|
return null;
|
|
5470
5470
|
}
|
|
5471
5471
|
}
|
|
5472
|
-
function isLoopbackHostname$
|
|
5472
|
+
function isLoopbackHostname$4(hostname) {
|
|
5473
5473
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
5474
5474
|
}
|
|
5475
5475
|
function hasActiveSessionPayload(payload) {
|
|
@@ -5762,7 +5762,7 @@ async function requireAtsProfilesSession() {
|
|
|
5762
5762
|
}
|
|
5763
5763
|
function resolveAtsProfilesApiTimeoutMs(endpoint) {
|
|
5764
5764
|
const url = parseUrlOrNull$2(endpoint);
|
|
5765
|
-
if (url && isLoopbackHostname$
|
|
5765
|
+
if (url && isLoopbackHostname$3(url.hostname)) return LOOPBACK_ATS_PROFILES_API_TIMEOUT_MS;
|
|
5766
5766
|
return DEFAULT_ATS_PROFILES_API_TIMEOUT_MS;
|
|
5767
5767
|
}
|
|
5768
5768
|
function parseUrlOrNull$2(value) {
|
|
@@ -5772,7 +5772,7 @@ function parseUrlOrNull$2(value) {
|
|
|
5772
5772
|
return null;
|
|
5773
5773
|
}
|
|
5774
5774
|
}
|
|
5775
|
-
function isLoopbackHostname$
|
|
5775
|
+
function isLoopbackHostname$3(hostname) {
|
|
5776
5776
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
5777
5777
|
}
|
|
5778
5778
|
function isSameStoredAuthSession(a, b) {
|
|
@@ -5908,11 +5908,11 @@ async function findAtsProfileByNameOrHandle(input) {
|
|
|
5908
5908
|
}
|
|
5909
5909
|
function isLoopbackProfileEndpoint(endpoint) {
|
|
5910
5910
|
const url = parseUrlOrNull$2(endpoint);
|
|
5911
|
-
return Boolean(url && isLoopbackHostname$
|
|
5911
|
+
return Boolean(url && isLoopbackHostname$3(url.hostname) && url.pathname.startsWith("/v1/profiles"));
|
|
5912
5912
|
}
|
|
5913
5913
|
function isHostedProfilesEndpoint(endpoint) {
|
|
5914
5914
|
const url = parseUrlOrNull$2(endpoint);
|
|
5915
|
-
return Boolean(url && !isLoopbackHostname$
|
|
5915
|
+
return Boolean(url && !isLoopbackHostname$3(url.hostname) && url.pathname.startsWith("/v1/profiles"));
|
|
5916
5916
|
}
|
|
5917
5917
|
function isRecord$5(value) {
|
|
5918
5918
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -12214,7 +12214,7 @@ function resolveAuthRequestCompatibility(input) {
|
|
|
12214
12214
|
const expectedGatewayHost = deriveGatewayHost(authBaseUrl);
|
|
12215
12215
|
const requestHost = requestUrl.host;
|
|
12216
12216
|
const authHost = authBaseUrl.host;
|
|
12217
|
-
if (isLoopbackHostname$
|
|
12217
|
+
if (isLoopbackHostname$2(requestUrl.hostname) && isLoopbackHostname$2(authBaseUrl.hostname)) return {
|
|
12218
12218
|
compatible: true,
|
|
12219
12219
|
reason: "loopback",
|
|
12220
12220
|
requestHost,
|
|
@@ -12278,7 +12278,7 @@ function parseUrlOrNull$1(value) {
|
|
|
12278
12278
|
return null;
|
|
12279
12279
|
}
|
|
12280
12280
|
}
|
|
12281
|
-
function isLoopbackHostname$
|
|
12281
|
+
function isLoopbackHostname$2(hostname) {
|
|
12282
12282
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
12283
12283
|
}
|
|
12284
12284
|
function isSecureTransportProtocol(protocol) {
|
|
@@ -76095,7 +76095,7 @@ function toAuthEndpoint(baseUrl, pathname) {
|
|
|
76095
76095
|
}
|
|
76096
76096
|
function buildSpaceWebUrl(baseUrl, spaceId) {
|
|
76097
76097
|
const url = new URL(baseUrl);
|
|
76098
|
-
if (isLoopbackHostname(url.hostname) && url.port === "8080") url.port = "3000";
|
|
76098
|
+
if (isLoopbackHostname$1(url.hostname) && url.port === "8080") url.port = "3000";
|
|
76099
76099
|
if (url.hostname === "gateway.ats.sh") {
|
|
76100
76100
|
url.hostname = "ats.sh";
|
|
76101
76101
|
url.port = "";
|
|
@@ -76108,7 +76108,7 @@ function buildSpaceWebUrl(baseUrl, spaceId) {
|
|
|
76108
76108
|
}
|
|
76109
76109
|
function resolveSpaceCreateAuthCheckTimeoutMs(endpoint) {
|
|
76110
76110
|
const url = parseUrlOrNull(endpoint);
|
|
76111
|
-
if (url && isLoopbackHostname(url.hostname)) return SPACE_CREATE_AUTH_CHECK_LOOPBACK_TIMEOUT_MS;
|
|
76111
|
+
if (url && isLoopbackHostname$1(url.hostname)) return SPACE_CREATE_AUTH_CHECK_LOOPBACK_TIMEOUT_MS;
|
|
76112
76112
|
return SPACE_CREATE_AUTH_CHECK_TIMEOUT_MS;
|
|
76113
76113
|
}
|
|
76114
76114
|
function parseUrlOrNull(value) {
|
|
@@ -76118,7 +76118,7 @@ function parseUrlOrNull(value) {
|
|
|
76118
76118
|
return null;
|
|
76119
76119
|
}
|
|
76120
76120
|
}
|
|
76121
|
-
function isLoopbackHostname(hostname) {
|
|
76121
|
+
function isLoopbackHostname$1(hostname) {
|
|
76122
76122
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
76123
76123
|
}
|
|
76124
76124
|
function emitSpaceCreateSuccessOutput(input) {
|
|
@@ -87695,6 +87695,7 @@ const PREPARE_SESSION_MAX_RECONNECT_ATTEMPTS = 3;
|
|
|
87695
87695
|
const PREPARE_SESSION_RECONNECT_DELAY_MS = 1e3;
|
|
87696
87696
|
const REPORT_RUNTIME_CONNECTION_MAX_ATTEMPTS = 12;
|
|
87697
87697
|
const REPORT_RUNTIME_CONNECTION_RETRY_DELAY_MS = 1e3;
|
|
87698
|
+
const BRING_AGENTS_AGENT_SELECTION_PATH = "/app/start/bring-agents/agents";
|
|
87698
87699
|
const TERMINAL_PREPARE_STEP_ORDER = [
|
|
87699
87700
|
"prepare_selected_agents",
|
|
87700
87701
|
"refresh_service",
|
|
@@ -87827,14 +87828,82 @@ async function resolveAgentSelection(input) {
|
|
|
87827
87828
|
});
|
|
87828
87829
|
}
|
|
87829
87830
|
if (hasAgentSelectionBeenSaved(input.snapshot)) return input.snapshot;
|
|
87830
|
-
|
|
87831
|
+
const setupPageUrl = buildPrepareSessionWebSelectionUrl({
|
|
87832
|
+
gatewayUrl: input.input.gatewayUrl,
|
|
87833
|
+
snapshot: input.snapshot
|
|
87834
|
+
});
|
|
87835
|
+
const openedSetupPage = await tryOpenPrepareSessionWebSelectionUrl({
|
|
87836
|
+
input: input.input,
|
|
87837
|
+
setupPageUrl
|
|
87838
|
+
});
|
|
87839
|
+
emitHumanStatus(input.input, "Waiting for ATS Web", [
|
|
87840
|
+
"Choose local agents on the setup page.",
|
|
87841
|
+
...formatPrepareSessionWebSelectionUrlLines({
|
|
87842
|
+
opened: openedSetupPage,
|
|
87843
|
+
setupPageUrl
|
|
87844
|
+
}),
|
|
87845
|
+
"Setup will continue here automatically."
|
|
87846
|
+
]);
|
|
87831
87847
|
return await waitForSnapshotWithProgress({
|
|
87832
87848
|
input: input.input,
|
|
87833
87849
|
stream: input.stream,
|
|
87834
87850
|
predicate: hasAgentSelectionBeenSaved,
|
|
87835
|
-
waitingMessage:
|
|
87851
|
+
waitingMessage: formatPrepareSessionWebSelectionWaitingMessage({ setupPageUrl })
|
|
87836
87852
|
});
|
|
87837
87853
|
}
|
|
87854
|
+
function buildPrepareSessionWebSelectionUrl(input) {
|
|
87855
|
+
const webBaseUrl = resolvePrepareSessionWebBaseUrl(input.gatewayUrl);
|
|
87856
|
+
if (!webBaseUrl) return null;
|
|
87857
|
+
const url = new URL(BRING_AGENTS_AGENT_SELECTION_PATH, webBaseUrl);
|
|
87858
|
+
url.search = buildPrepareSessionWebSelectionSearch(input.snapshot).toString();
|
|
87859
|
+
return url.toString();
|
|
87860
|
+
}
|
|
87861
|
+
function buildPrepareSessionWebSelectionSearch(snapshot) {
|
|
87862
|
+
const params = new URLSearchParams();
|
|
87863
|
+
params.set("setup", "this-computer");
|
|
87864
|
+
if (snapshot.targetSpaceId && snapshot.humanProfileId) {
|
|
87865
|
+
params.set("returnTo", "space");
|
|
87866
|
+
params.set("spaceId", snapshot.targetSpaceId);
|
|
87867
|
+
params.set("profileId", snapshot.humanProfileId);
|
|
87868
|
+
return params;
|
|
87869
|
+
}
|
|
87870
|
+
params.set("returnTo", "agents");
|
|
87871
|
+
return params;
|
|
87872
|
+
}
|
|
87873
|
+
function resolvePrepareSessionWebBaseUrl(gatewayUrl) {
|
|
87874
|
+
try {
|
|
87875
|
+
const url = new URL(gatewayUrl);
|
|
87876
|
+
if (isLoopbackHostname(url.hostname) && url.port === "8080") url.port = "3000";
|
|
87877
|
+
if (url.hostname === "gateway.ats.sh") {
|
|
87878
|
+
url.hostname = "ats.sh";
|
|
87879
|
+
url.port = "";
|
|
87880
|
+
url.protocol = "https:";
|
|
87881
|
+
}
|
|
87882
|
+
url.pathname = "/";
|
|
87883
|
+
url.search = "";
|
|
87884
|
+
url.hash = "";
|
|
87885
|
+
return url.toString();
|
|
87886
|
+
} catch {
|
|
87887
|
+
return null;
|
|
87888
|
+
}
|
|
87889
|
+
}
|
|
87890
|
+
function isLoopbackHostname(hostname) {
|
|
87891
|
+
const normalizedHostname = hostname.toLowerCase();
|
|
87892
|
+
return normalizedHostname === "localhost" || normalizedHostname === "127.0.0.1" || normalizedHostname === "::1";
|
|
87893
|
+
}
|
|
87894
|
+
async function tryOpenPrepareSessionWebSelectionUrl(input) {
|
|
87895
|
+
if (!(input.setupPageUrl && input.input.runtime.resolvedView === "human" && input.input.interactive && process$1.stdout.isTTY)) return false;
|
|
87896
|
+
return await tryOpenUrl(input.setupPageUrl);
|
|
87897
|
+
}
|
|
87898
|
+
function formatPrepareSessionWebSelectionUrlLines(input) {
|
|
87899
|
+
if (!input.setupPageUrl) return ["Return to ATS Web to finish choosing agents."];
|
|
87900
|
+
if (input.opened) return ["ATS opened the setup page in your browser.", `Setup page: ${input.setupPageUrl}`];
|
|
87901
|
+
return [`Open this setup page: ${input.setupPageUrl}`];
|
|
87902
|
+
}
|
|
87903
|
+
function formatPrepareSessionWebSelectionWaitingMessage(input) {
|
|
87904
|
+
const baseMessage = "Still waiting for your choice in ATS Web. Keep this Terminal open";
|
|
87905
|
+
return input.setupPageUrl ? `${baseMessage}. Setup page: ${input.setupPageUrl}` : baseMessage;
|
|
87906
|
+
}
|
|
87838
87907
|
function resolveTerminalSelectedLocalAgentIds(input) {
|
|
87839
87908
|
if (input.selection.mode === "none") return [];
|
|
87840
87909
|
const catalog = input.snapshot.localAgentCatalog;
|